diff --git a/.golangci.yaml b/.golangci.yaml index 95c66cc69f73..40bfa36e1a64 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -105,6 +105,7 @@ linters: - typecheck - unconvert - unused + - usestdlibvars run: go: '1.22' diff --git a/integration/registry_test.go b/integration/registry_test.go index aded09adce35..25ddaf5b2814 100644 --- a/integration/registry_test.go +++ b/integration/registry_test.go @@ -334,7 +334,7 @@ func requestRegistryToken(imageRef name.Reference, baseDir string, opt registryO } // Get a registry token - req, err := http.NewRequest("GET", fmt.Sprintf("%s/auth", opt.AuthURL), nil) + req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/auth", opt.AuthURL), nil) if err != nil { return "", err } diff --git a/pkg/dependency/parser/java/pom/parse.go b/pkg/dependency/parser/java/pom/parse.go index 2c8a194ea50b..60a83ba9d81b 100644 --- a/pkg/dependency/parser/java/pom/parse.go +++ b/pkg/dependency/parser/java/pom/parse.go @@ -703,7 +703,7 @@ func (p *Parser) remoteRepoRequest(repo string, paths []string) (*http.Request, paths = append([]string{repoURL.Path}, paths...) repoURL.Path = path.Join(paths...) - req, err := http.NewRequest("GET", repoURL.String(), http.NoBody) + req, err := http.NewRequest(http.MethodGet, repoURL.String(), http.NoBody) if err != nil { return nil, xerrors.Errorf("unable to create HTTP request: %w", err) } diff --git a/pkg/iac/adapters/terraform/aws/apigateway/adapt_test.go b/pkg/iac/adapters/terraform/aws/apigateway/adapt_test.go index 65393ae82f82..8d2b0155fee5 100644 --- a/pkg/iac/adapters/terraform/aws/apigateway/adapt_test.go +++ b/pkg/iac/adapters/terraform/aws/apigateway/adapt_test.go @@ -1,6 +1,7 @@ package apigateway import ( + "net/http" "testing" "github.com/stretchr/testify/assert" @@ -72,7 +73,7 @@ resource "aws_apigatewayv2_domain_name" "example" { { Methods: []v1.Method{ { - HTTPMethod: String("GET"), + HTTPMethod: String(http.MethodGet), AuthorizationType: String("NONE"), APIKeyRequired: Bool(false), }, diff --git a/pkg/iac/adapters/terraform/aws/apigateway/apiv1_test.go b/pkg/iac/adapters/terraform/aws/apigateway/apiv1_test.go index cf69e8d0ee23..9932ac864e7b 100644 --- a/pkg/iac/adapters/terraform/aws/apigateway/apiv1_test.go +++ b/pkg/iac/adapters/terraform/aws/apigateway/apiv1_test.go @@ -1,6 +1,7 @@ package apigateway import ( + "net/http" "testing" "github.com/aquasecurity/trivy/internal/testutil" @@ -35,7 +36,7 @@ resource "aws_api_gateway_method" "example" { `, expected: []v1.Method{ { - HTTPMethod: String("GET"), + HTTPMethod: String(http.MethodGet), AuthorizationType: String("NONE"), APIKeyRequired: Bool(false), }, @@ -63,7 +64,7 @@ resource "aws_api_gateway_method" "example" { `, expected: []v1.Method{ { - HTTPMethod: String("GET"), + HTTPMethod: String(http.MethodGet), AuthorizationType: String("NONE"), APIKeyRequired: Bool(true), },