From 55f415b9b756beea66b6dc93132cac1c3eeb0bce Mon Sep 17 00:00:00 2001 From: Tom Wieczorek Date: Wed, 13 Nov 2024 09:09:30 +0100 Subject: [PATCH] Enable usestdlibvars linter ... and fix lints on the way. Signed-off-by: Tom Wieczorek --- .golangci.yml | 21 +++++++++++---------- internal/http/download.go | 2 +- pkg/autopilot/channels/channelclient.go | 2 +- pkg/component/worker/static_pods_test.go | 2 +- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 5e18653cfca3..9bf79536c81f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,16 +10,17 @@ run: linters: enable: - - copyloopvar # Detects unnecessary copies of loop variables for Go >= 1.22 - - depguard # Checks if package imports are in a list of acceptable packages - - dupword # Finds word repetitions - - errorlint # Find code that will cause problems with Go's error wrapping scheme - - gofmt # Checks whether code was gofmt-ed - - goheader # Checks is file headers matche a given pattern - - intrange # Checking for loops that could use an integer range - - revive # Stricter drop-in replacement for golint - - testifylint # Checks usage of github.com/stretchr/testify - - unconvert # Checks for unnecessary type conversions + - copyloopvar # Detects unnecessary copies of loop variables for Go >= 1.22 + - depguard # Checks if package imports are in a list of acceptable packages + - dupword # Finds word repetitions + - errorlint # Find code that will cause problems with Go's error wrapping scheme + - gofmt # Checks whether code was gofmt-ed + - goheader # Checks is file headers matche a given pattern + - intrange # Checking for loops that could use an integer range + - revive # Stricter drop-in replacement for golint + - testifylint # Checks usage of github.com/stretchr/testify + - unconvert # Checks for unnecessary type conversions + - usestdlibvars # Checks for things that are provided by the standard library linters-settings: depguard: diff --git a/internal/http/download.go b/internal/http/download.go index 10ac0fd9a028..2e8f40ddad84 100644 --- a/internal/http/download.go +++ b/internal/http/download.go @@ -59,7 +59,7 @@ func Download(ctx context.Context, url string, target io.Writer, options ...Down // Prepare the client and the request. client := http.Client{Transport: transport} - req, err := http.NewRequest("GET", url, nil) + req, err := http.NewRequest(http.MethodGet, url, nil) if err != nil { return fmt.Errorf("invalid download request: %w", err) } diff --git a/pkg/autopilot/channels/channelclient.go b/pkg/autopilot/channels/channelclient.go index 6fa84a2e1a1a..59f6fa0464d6 100644 --- a/pkg/autopilot/channels/channelclient.go +++ b/pkg/autopilot/channels/channelclient.go @@ -56,7 +56,7 @@ func (c *ChannelClient) GetLatest(ctx context.Context, headers map[string]string var v VersionInfo - req, err := http.NewRequestWithContext(ctx, "GET", c.channelURL, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.channelURL, nil) if err != nil { return v, err } diff --git a/pkg/component/worker/static_pods_test.go b/pkg/component/worker/static_pods_test.go index 1f41a916c5af..6596874aa320 100644 --- a/pkg/component/worker/static_pods_test.go +++ b/pkg/component/worker/static_pods_test.go @@ -328,7 +328,7 @@ func TestStaticPods_Lifecycle(t *testing.T) { url, err := underTest.ManifestURL() require.NoError(t, err) - req, err := http.NewRequest("GET", url, nil) + req, err := http.NewRequest(http.MethodGet, url, nil) require.NoError(t, err) ctx, cancel := context.WithTimeout(ctx, 3*time.Second)