From 2f72d325dc1b42ace3bb550978a1731c3fadb16d Mon Sep 17 00:00:00 2001 From: Ash McKenzie Date: Sat, 3 Jun 2023 13:29:27 +1000 Subject: [PATCH 1/2] Fix go-staticcheck SA1029 issues --- entry_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/entry_test.go b/entry_test.go index 41c47a2..d702661 100644 --- a/entry_test.go +++ b/entry_test.go @@ -10,6 +10,8 @@ import ( "github.com/stretchr/testify/assert" ) +type contextKeyType string + func TestEntryWithError(t *testing.T) { assert := assert.New(t) @@ -36,7 +38,8 @@ func TestEntryWithError(t *testing.T) { func TestEntryWithContext(t *testing.T) { assert := assert.New(t) - ctx := context.WithValue(context.Background(), "foo", "bar") + var contextKey contextKeyType = "foo" + ctx := context.WithValue(context.Background(), contextKey, "bar") assert.Equal(ctx, WithContext(ctx).Context) @@ -56,11 +59,13 @@ func TestEntryWithContextCopiesData(t *testing.T) { parentEntry := NewEntry(logger).WithField("parentKey", "parentValue") // Create two children Entry objects from the parent in different contexts - ctx1 := context.WithValue(context.Background(), "foo", "bar") + var contextKey1 contextKeyType = "foo" + ctx1 := context.WithValue(context.Background(), contextKey1, "bar") childEntry1 := parentEntry.WithContext(ctx1) assert.Equal(ctx1, childEntry1.Context) - ctx2 := context.WithValue(context.Background(), "bar", "baz") + var contextKey2 contextKeyType = "bar" + ctx2 := context.WithValue(context.Background(), contextKey2, "baz") childEntry2 := parentEntry.WithContext(ctx2) assert.Equal(ctx2, childEntry2.Context) assert.NotEqual(ctx1, ctx2) From 80d649c2d1dc6175ebae526063fc1d351b883587 Mon Sep 17 00:00:00 2001 From: Ash McKenzie Date: Sat, 3 Jun 2023 13:31:39 +1000 Subject: [PATCH 2/2] Fix go-staticcheck S1021 issues --- logrus_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/logrus_test.go b/logrus_test.go index 4edee28..72a02de 100644 --- a/logrus_test.go +++ b/logrus_test.go @@ -544,8 +544,7 @@ func TestParseLevel(t *testing.T) { } func TestLevelString(t *testing.T) { - var loggerlevel Level - loggerlevel = 32000 + var loggerlevel Level = 32000 _ = loggerlevel.String() }