diff --git a/.golangci.yml b/.golangci.yml index 512e11a3740..a86971538da 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -32,6 +32,7 @@ linters: - unconvert - unparam - unused + - usestdlibvars issues: # Maximum issues count per one linter. @@ -68,6 +69,7 @@ issues: linters: - gosec - perfsprint + - usestdlibvars include: # revive exported should have comment or be unexported. - EXC0012 diff --git a/detectors/azure/azurevm/vm.go b/detectors/azure/azurevm/vm.go index e1005b0db87..cd3a3ef27a1 100644 --- a/detectors/azure/azurevm/vm.go +++ b/detectors/azure/azurevm/vm.go @@ -89,7 +89,7 @@ func (detector *ResourceDetector) getJSONMetadata(ctx context.Context) ([]byte, client := http.Client{Transport: pTransport} - req, err := http.NewRequestWithContext(ctx, "GET", detector.endpoint, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, detector.endpoint, nil) if err != nil { return nil, false, err } diff --git a/instrumentation/net/http/httptrace/otelhttptrace/example/client/client.go b/instrumentation/net/http/httptrace/otelhttptrace/example/client/client.go index 24a98265d4e..d685ce61bf9 100644 --- a/instrumentation/net/http/httptrace/otelhttptrace/example/client/client.go +++ b/instrumentation/net/http/httptrace/otelhttptrace/example/client/client.go @@ -79,7 +79,7 @@ func main() { ctx, span := tr.Start(ctx, "say hello", trace.WithAttributes(semconv.PeerService("ExampleService"))) defer span.End() - req, _ := http.NewRequestWithContext(ctx, "GET", *url, nil) + req, _ := http.NewRequestWithContext(ctx, http.MethodGet, *url, nil) fmt.Printf("Sending request...\n") res, err := client.Do(req) diff --git a/instrumentation/net/http/otelhttp/client.go b/instrumentation/net/http/otelhttp/client.go index 6aae83bfd20..b25641c55d3 100644 --- a/instrumentation/net/http/otelhttp/client.go +++ b/instrumentation/net/http/otelhttp/client.go @@ -18,7 +18,7 @@ var DefaultClient = &http.Client{Transport: NewTransport(http.DefaultTransport)} // Get is a convenient replacement for http.Get that adds a span around the request. func Get(ctx context.Context, targetURL string) (resp *http.Response, err error) { - req, err := http.NewRequestWithContext(ctx, "GET", targetURL, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, targetURL, nil) if err != nil { return nil, err } @@ -27,7 +27,7 @@ func Get(ctx context.Context, targetURL string) (resp *http.Response, err error) // Head is a convenient replacement for http.Head that adds a span around the request. func Head(ctx context.Context, targetURL string) (resp *http.Response, err error) { - req, err := http.NewRequestWithContext(ctx, "HEAD", targetURL, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodHead, targetURL, nil) if err != nil { return nil, err } @@ -36,7 +36,7 @@ func Head(ctx context.Context, targetURL string) (resp *http.Response, err error // Post is a convenient replacement for http.Post that adds a span around the request. func Post(ctx context.Context, targetURL, contentType string, body io.Reader) (resp *http.Response, err error) { - req, err := http.NewRequestWithContext(ctx, "POST", targetURL, body) + req, err := http.NewRequestWithContext(ctx, http.MethodPost, targetURL, body) if err != nil { return nil, err } diff --git a/instrumentation/net/http/otelhttp/example/client/client.go b/instrumentation/net/http/otelhttp/example/client/client.go index 0fd9e070df1..0dfa44f493c 100644 --- a/instrumentation/net/http/otelhttp/example/client/client.go +++ b/instrumentation/net/http/otelhttp/example/client/client.go @@ -66,7 +66,7 @@ func main() { err = func(ctx context.Context) error { ctx, span := tr.Start(ctx, "say hello", trace.WithAttributes(semconv.PeerService("ExampleService"))) defer span.End() - req, _ := http.NewRequestWithContext(ctx, "GET", *url, nil) + req, _ := http.NewRequestWithContext(ctx, http.MethodGet, *url, nil) fmt.Printf("Sending request...\n") res, err := client.Do(req)