Actually add all build flags, so we also get things like -race.
Fixes #10228.
Change-Id: I5f77dda9d1ee3208e1833702f12f68c2731c4b22
Reviewed-on: https://go-review.googlesource.com/10697
Reviewed-by: Russ Cox <rsc@golang.org>
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.
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.
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
--- /dev/null
+// +build tagtest
+
+package p
+
+import "fmt"
+
+func g() {
+ fmt.Printf("%d", 3, 4)
+}
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.
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.
`,
}