From 10d99861de873ba2a837a6db014f498620b405e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 30 Dec 2025 22:30:17 +0200 Subject: [PATCH 1/3] chore(golangci-lint): upgrade to 2.7.2 --- .github/workflows/ci.yaml | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/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 From 4b2f22c66455e5aaa1537c430e3a2da17194b997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 30 Dec 2025 22:35:14 +0200 Subject: [PATCH 2/3] refactor: avoid/hush revive warning on stdlib json package name clash --- internal/encoding/json/codec.go | 2 +- internal/encoding/json/codec_test.go | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) 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{} From 089386779411cc0b077ecc8778238b95b60f544b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 30 Dec 2025 22:36:57 +0200 Subject: [PATCH 3/3] refactor(golangci-lint): enable moderize, address findings --- .golangci.yaml | 1 + viper.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) 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/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 }