From 3794edab06bf4551bd950e5fe0eed8c00ec7686a Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sun, 24 Nov 2024 13:00:59 +0100 Subject: [PATCH] [chore]: enable usestdlibvars linter Signed-off-by: Matthieu MOREL --- .golangci.yml | 1 + propagation/baggage_test.go | 8 ++++---- propagation/trace_context_benchmark_test.go | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 43ef9aaff19..ce3f40b609c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -31,6 +31,7 @@ linters: - unconvert - unused - unparam + - usestdlibvars issues: # Maximum issues count per one linter. diff --git a/propagation/baggage_test.go b/propagation/baggage_test.go index e6a71540fa2..4559a808fe2 100644 --- a/propagation/baggage_test.go +++ b/propagation/baggage_test.go @@ -117,7 +117,7 @@ func TestExtractValidBaggageFromHTTPReq(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - req, _ := http.NewRequest("GET", "http://example.com", nil) + req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil) req.Header.Set("baggage", tt.header) ctx := context.Background() @@ -173,7 +173,7 @@ func TestExtractInvalidDistributedContextFromHTTPReq(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - req, _ := http.NewRequest("GET", "http://example.com", nil) + req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil) req.Header.Set("baggage", tt.header) expected := tt.has.Baggage(t) @@ -226,7 +226,7 @@ func TestInjectBaggageToHTTPReq(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - req, _ := http.NewRequest("GET", "http://example.com", nil) + req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil) ctx := baggage.ContextWithBaggage(context.Background(), tt.mems.Baggage(t)) propagator.Inject(ctx, propagation.HeaderCarrier(req.Header)) @@ -273,7 +273,7 @@ func TestBaggageInjectExtractRoundtrip(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { b := tt.mems.Baggage(t) - req, _ := http.NewRequest("GET", "http://example.com", nil) + req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil) ctx := baggage.ContextWithBaggage(context.Background(), b) propagator.Inject(ctx, propagation.HeaderCarrier(req.Header)) diff --git a/propagation/trace_context_benchmark_test.go b/propagation/trace_context_benchmark_test.go index 7b7ea5788dd..041d2f664ee 100644 --- a/propagation/trace_context_benchmark_test.go +++ b/propagation/trace_context_benchmark_test.go @@ -56,7 +56,7 @@ func BenchmarkExtract(b *testing.B) { func extractSubBenchmarks(b *testing.B, fn func(*testing.B, *http.Request)) { b.Run("Sampled", func(b *testing.B) { - req, _ := http.NewRequest("GET", "http://example.com", nil) + req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil) req.Header.Set("traceparent", "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01") b.ReportAllocs() @@ -64,14 +64,14 @@ func extractSubBenchmarks(b *testing.B, fn func(*testing.B, *http.Request)) { }) b.Run("BogusVersion", func(b *testing.B) { - req, _ := http.NewRequest("GET", "http://example.com", nil) + req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil) req.Header.Set("traceparent", "qw-00000000000000000000000000000000-0000000000000000-01") b.ReportAllocs() fn(b, req) }) b.Run("FutureAdditionalData", func(b *testing.B) { - req, _ := http.NewRequest("GET", "http://example.com", nil) + req, _ := http.NewRequest(http.MethodGet, "http://example.com", nil) req.Header.Set("traceparent", "02-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-09-XYZxsf09") b.ReportAllocs() fn(b, req)