diff options
author | Russ Cox <rsc@golang.org> | 2014-10-16 15:00:08 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-10-16 15:00:08 -0400 |
commit | 78db2eb9c66d478bee0d56edcc55d4f865f8c6c7 (patch) | |
tree | d08da7ddd82570422ae87dc9d3ac061f8ce3b648 /src/cmd/go/vet.go | |
parent | af64ab79c0ad72decf083d78cf54257d009741b5 (diff) | |
parent | 25c63c2c30f4807b073f849d248144d97893ce70 (diff) | |
download | go-78db2eb9c66d478bee0d56edcc55d4f865f8c6c7.tar.gz |
all: merge default branch into dev.garbage
hg was unable to create a CL on the code review server for this,
so I am submitting the merge by hand.
The only manual edits are in mgc0.c, to reapply the
removal of cached/ncached to the new code.
Diffstat (limited to 'src/cmd/go/vet.go')
-rw-r--r-- | src/cmd/go/vet.go | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/cmd/go/vet.go b/src/cmd/go/vet.go index ffb431837..de7befc61 100644 --- a/src/cmd/go/vet.go +++ b/src/cmd/go/vet.go @@ -4,6 +4,8 @@ package main +import "path/filepath" + func init() { addBuildFlagsNX(cmdVet) } @@ -28,10 +30,21 @@ See also: go fmt, go fix. } func runVet(cmd *Command, args []string) { - for _, pkg := range packages(args) { - // Use pkg.gofiles instead of pkg.Dir so that - // the command only applies to this package, - // not to packages in subdirectories. - run(tool("vet"), relPaths(stringList(pkg.gofiles, pkg.sfiles))) + for _, p := range packages(args) { + // Vet expects to be given a set of files all from the same package. + // Run once for package p and once for package p_test. + if len(p.GoFiles)+len(p.CgoFiles)+len(p.TestGoFiles) > 0 { + runVetFiles(p, stringList(p.GoFiles, p.CgoFiles, p.TestGoFiles, p.SFiles)) + } + if len(p.XTestGoFiles) > 0 { + runVetFiles(p, stringList(p.XTestGoFiles)) + } + } +} + +func runVetFiles(p *Package, files []string) { + for i := range files { + files[i] = filepath.Join(p.Dir, files[i]) } + run(tool("vet"), relPaths(files)) } |