From 6af9635fb8a002f563a1765f7ab2bd97d4e4d4df Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 30 Jan 2023 14:23:48 -0500 Subject: [PATCH] cmd/go: enable vet directive analyzer during 'go test' For #56986, run the new directive analyzer during 'go test', to diagnose problems that would otherwise be missed, like //go:debug appearing in the wrong place in a file or in the wrong files. Change-Id: I1ac230c3c67e58b5e584128e0ec6ff482cb225f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/464135 Run-TryBot: Russ Cox TryBot-Result: Gopher Robot Reviewed-by: Alan Donovan --- src/cmd/go/alldocs.go | 4 ++-- src/cmd/go/internal/test/test.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 084a104600..6b91b53347 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -1687,8 +1687,8 @@ // and its test source files to identify significant problems. If go vet // finds any problems, go test reports those and does not run the test // binary. Only a high-confidence subset of the default go vet checks are -// used. That subset is: 'atomic', 'bool', 'buildtags', 'errorsas', -// 'ifaceassert', 'nilfunc', 'printf', and 'stringintconv'. You can see +// used. That subset is: atomic, bool, buildtags, directive, errorsas, +// ifaceassert, nilfunc, printf, and stringintconv. You can see // the documentation for these and other vet tests via "go doc cmd/vet". // To disable the running of go vet, use the -vet=off flag. To run all // checks, use the -vet=all flag. diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index aaeb70a544..904144f279 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -76,8 +76,8 @@ As part of building a test binary, go test runs go vet on the package and its test source files to identify significant problems. If go vet finds any problems, go test reports those and does not run the test binary. Only a high-confidence subset of the default go vet checks are -used. That subset is: 'atomic', 'bool', 'buildtags', 'errorsas', -'ifaceassert', 'nilfunc', 'printf', and 'stringintconv'. You can see +used. That subset is: atomic, bool, buildtags, directive, errorsas, +ifaceassert, nilfunc, printf, and stringintconv. You can see the documentation for these and other vet tests via "go doc cmd/vet". To disable the running of go vet, use the -vet=off flag. To run all checks, use the -vet=all flag. @@ -642,6 +642,7 @@ var defaultVetFlags = []string{ // "-cgocall", // "-composites", // "-copylocks", + "-directive", "-errorsas", // "-httpresponse", "-ifaceassert", -- 2.48.1