diff --git a/.golangci.yml b/.golangci.yml index da9eb2c213..88b12570b6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -28,6 +28,7 @@ linters: - fatcontext - gocritic - godot + - govet - loggercheck - misspell - nilnesserr @@ -108,6 +109,11 @@ linters: - (*net/http.Server).Shutdown # Never check for rollback errors as Rollback() is called when a previous error was detected. - (github.com/prometheus/prometheus/storage.Appender).Rollback + govet: + disable: + - shadow + - fieldalignment + enable-all: true perfsprint: # Optimizes even if it requires an int or uint type cast. int-conversion: true diff --git a/documentation/examples/custom-sd/adapter-usage/main.go b/documentation/examples/custom-sd/adapter-usage/main.go index 128132a8d2..ef9f51487a 100644 --- a/documentation/examples/custom-sd/adapter-usage/main.go +++ b/documentation/examples/custom-sd/adapter-usage/main.go @@ -221,10 +221,8 @@ func (d *discovery) Run(ctx context.Context, ch chan<- []*targetgroup.Group) { } } d.oldSourceList = newSourceList - if err == nil { - // We're returning all Consul services as a single targetgroup. - ch <- tgs - } + // We're returning all Consul services as a single targetgroup. + ch <- tgs // Wait for ticker or exit when ctx is closed. select { case <-c: diff --git a/promql/engine_internal_test.go b/promql/engine_internal_test.go index f873b6fabd..8662891da6 100644 --- a/promql/engine_internal_test.go +++ b/promql/engine_internal_test.go @@ -39,10 +39,9 @@ func TestRecoverEvaluatorRuntime(t *testing.T) { require.Contains(t, output.String(), "sum(up)") }() defer ev.recover(expr, nil, &err) - // Cause a runtime panic. var a []int - a[123] = 1 + a[123] = 1 //nolint:govet // This is intended to cause a runtime panic. } func TestRecoverEvaluatorError(t *testing.T) { diff --git a/promql/parser/parse_test.go b/promql/parser/parse_test.go index 24c920fe29..d239581ece 100644 --- a/promql/parser/parse_test.go +++ b/promql/parser/parse_test.go @@ -5526,7 +5526,7 @@ func TestRecoverParserRuntime(t *testing.T) { defer p.recover(&err) // Cause a runtime panic. var a []int - a[123] = 1 + a[123] = 1 //nolint:govet // This is intended to cause a runtime panic. } func TestRecoverParserError(t *testing.T) {