Commit bbc4351e authored by Rob Pike's avatar Rob Pike

cmd/go: add -tags option to go vet

Actually add all build flags, so we also get things like -race.

Fixes #10228.

Change-Id: I5f77dda9d1ee3208e1833702f12f68c2731c4b22
Reviewed-on: https://go-review.googlesource.com/10697Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent 3a1f1637
......@@ -699,7 +699,7 @@ Run go tool vet on packages
Usage:
go vet [-n] [-x] [packages]
go vet [-n] [-x] [build flags] [packages]
Vet runs the Go vet command on the packages named by the import paths.
......@@ -711,6 +711,8 @@ To run the vet tool with specific options, run 'go tool vet'.
The -n flag prints commands that would be executed.
The -x flag prints commands as they are executed.
For more about build flags, see 'go help build'.
See also: go fmt, go fix.
......
......@@ -1290,6 +1290,22 @@ fi
unset GOPATH
rm -rf $d
TEST go vet with -tags
d=$(mktemp -d -t testgoXXX)
export GOPATH=$d
./testgo get golang.org/x/tools/cmd/vet
export GOPATH=$(pwd)/testdata
if ./testgo vet -tags tagtest vetpkg >$d/err 2>&1; then
echo "go vet vetpkg passes incorrectly"
ok=false
elif ! grep -q 'c\.go.*wrong number of args for format' $d/err; then
echo "go vet vetpkg did not scan tagged file"
cat $d/err
ok=false
fi
unset GOPATH
rm -rf $d
TEST go get ./rsc.io/toolstash '(golang.org/issue/9767)'
d=$(TMPDIR=/var/tmp mktemp -d -t testgoXXX)
export GOPATH=$d
......
// +build tagtest
package p
import "fmt"
func g() {
fmt.Printf("%d", 3, 4)
}
......@@ -7,12 +7,12 @@ package main
import "path/filepath"
func init() {
addBuildFlagsNX(cmdVet)
addBuildFlags(cmdVet)
}
var cmdVet = &Command{
Run: runVet,
UsageLine: "vet [-n] [-x] [packages]",
UsageLine: "vet [-n] [-x] [build flags] [packages]",
Short: "run go tool vet on packages",
Long: `
Vet runs the Go vet command on the packages named by the import paths.
......@@ -25,6 +25,8 @@ To run the vet tool with specific options, run 'go tool vet'.
The -n flag prints commands that would be executed.
The -x flag prints commands as they are executed.
For more about build flags, see 'go help build'.
See also: go fmt, go fix.
`,
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment