diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ca134e52c..6b13ea84e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -83,7 +83,7 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0 with: - version: v2.4.0 + version: v2.7.2 dev: name: Developer environment diff --git a/.golangci.yaml b/.golangci.yaml index 50a9d6cff..8ca8fdd8c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -19,6 +19,7 @@ linters: - ineffassign - makezero - misspell + - modernize - nakedret - nilerr - noctx diff --git a/Makefile b/Makefile index a77b9c81c..3ebacf8f1 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ endif # Dependency versions GOTESTSUM_VERSION = 1.9.0 -GOLANGCI_VERSION = 1.53.3 +GOLANGCI_VERSION = 2.7.2 # Add the ability to override some variables # Use with care diff --git a/internal/encoding/json/codec.go b/internal/encoding/json/codec.go index 3c6825b3c..dab003c0a 100644 --- a/internal/encoding/json/codec.go +++ b/internal/encoding/json/codec.go @@ -1,4 +1,4 @@ -package json +package json //revive:disable-line:var-naming import ( "encoding/json" diff --git a/internal/encoding/json/codec_test.go b/internal/encoding/json/codec_test.go index 95c9b4fb4..72190a378 100644 --- a/internal/encoding/json/codec_test.go +++ b/internal/encoding/json/codec_test.go @@ -1,10 +1,12 @@ -package json +package json_test import ( "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + + "github.com/spf13/viper/internal/encoding/json" ) // encoded form of the data. @@ -54,7 +56,7 @@ var data = map[string]any{ } func TestCodec_Encode(t *testing.T) { - codec := Codec{} + codec := json.Codec{} b, err := codec.Encode(data) require.NoError(t, err) @@ -64,7 +66,7 @@ func TestCodec_Encode(t *testing.T) { func TestCodec_Decode(t *testing.T) { t.Run("OK", func(t *testing.T) { - codec := Codec{} + codec := json.Codec{} v := map[string]any{} @@ -75,7 +77,7 @@ func TestCodec_Decode(t *testing.T) { }) t.Run("InvalidData", func(t *testing.T) { - codec := Codec{} + codec := json.Codec{} v := map[string]any{} diff --git a/viper.go b/viper.go index 2d5158cbd..3c92f2865 100644 --- a/viper.go +++ b/viper.go @@ -620,7 +620,7 @@ func (v *Viper) isPathShadowedInDeepMap(path []string, m map[string]any) string // "foo.bar.baz" in a lower-priority map func (v *Viper) isPathShadowedInFlatMap(path []string, mi any) string { // unify input map - var m map[string]interface{} + var m map[string]any switch miv := mi.(type) { case map[string]string: m = castMapStringToMapInterface(miv) @@ -1030,8 +1030,8 @@ func stringToWeakSliceHookFunc(sep string) mapstructure.DecodeHookFunc { return func( f reflect.Type, t reflect.Type, - data interface{}, - ) (interface{}, error) { + data any, + ) (any, error) { if f.Kind() != reflect.String || t.Kind() != reflect.Slice { return data, nil }