Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: document vet tests enabled during go test #24009

Closed
abraithwaite opened this issue Feb 21, 2018 · 2 comments
Closed

cmd/go: document vet tests enabled during go test #24009

abraithwaite opened this issue Feb 21, 2018 · 2 comments

Comments

@abraithwaite
Copy link
Contributor

Go 1.10 enables a subset of vet commands during test.

I could not find which commands where implemented without going to the source:

// testVetFlags is the list of flags to pass to vet when invoked automatically during go test.
var testVetFlags = []string{
// TODO(rsc): Decide which tests are enabled by default.
// See golang.org/issue/18085.
// "-asmdecl",
// "-assign",
"-atomic",
"-bool",
"-buildtags",
// "-cgocall",
// "-composites",
// "-copylocks",
// "-httpresponse",
// "-lostcancel",
// "-methods",
"-nilfunc",
"-printf",
// "-rangeloops",
// "-shift",
// "-structtags",
// "-tests",
// "-unreachable",
// "-unsafeptr",
// "-unusedresult",
}

It would be nice to have these in go help test.

@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Feb 22, 2018
@ianlancetaylor ianlancetaylor changed the title cmd/vet: document vet tests enabled during go test cmd/go: document vet tests enabled during go test Feb 22, 2018
@bcmills
Copy link
Contributor

bcmills commented Mar 9, 2018

The 1.10 release notes say:

The go test command now automatically runs go vet on the package being tested, to identify significant problems before running the test. Any such problems are treated like build errors and prevent execution of the test. Only a high-confidence subset of the available go vet checks are enabled for this automatic check. To disable the running of go vet, use go test -vet=off.

That kind of buries the lede: the fact that it only runs a subset by default is important, especially since some of the checks that are not currently enabled detect significant errors (see #24112).

I'm not sure whether it's too late to revise the release notes, but it might be clearer to move that information up front:

The go test command now automatically runs a high-confidence subset of go vet checks on the package being tested, to identify significant problems before running the test. Any such problems are treated like build errors and prevent execution of the test. To disable the running of go vet, use go test -vet off.

It would also be helpful to document how to add more flags to the default set, or whether that's even possible. (If I run go test -vet all, is that expected to do the right thing?)

@gopherbot
Copy link

Change https://golang.org/cl/107077 mentions this issue: cmd/go: document which vet tests are enabled during go test

@golang golang locked and limited conversation to collaborators Apr 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants