]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: set DepOnly on package when calling go list -deps
authorPaul Jolly <paul@myitcv.io>
Fri, 11 May 2018 14:02:45 +0000 (15:02 +0100)
committerPaul Jolly <paul@myitcv.org.uk>
Mon, 11 Jun 2018 18:46:47 +0000 (18:46 +0000)
Currently .DepOnly is set when go list -test is invoked to help
distinguish those packages that matched the command line spec from those
which are dependencies (of test packages). This is also useful when
calling go list -deps for the same reason.

Change-Id: Ifc0e68dad0fd01355928793ef803691dee5f4f29
Reviewed-on: https://go-review.googlesource.com/112755
Run-TryBot: Paul Jolly <paul@myitcv.org.uk>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/go/go_test.go
src/cmd/go/internal/list/list.go

index a44866f6b23b9767f5afdaa1ddc08a8ced0962ab..abe23ff52dd5d9b764c527eb3029af44e71c6d27 100644 (file)
@@ -1975,6 +1975,10 @@ func TestGoListTest(t *testing.T) {
 
        tg.run("list", "-test", "runtime/cgo")
        tg.grepStdout(`^runtime/cgo$`, "missing runtime/cgo")
+
+       tg.run("list", "-deps", "-f", "{{if .DepOnly}}{{.ImportPath}}{{end}}", "sort")
+       tg.grepStdout(`^reflect$`, "missing reflect")
+       tg.grepStdoutNot(`^sort`, "unexpected sort")
 }
 
 func TestGoListCgo(t *testing.T) {
index 7261d24839626dd4fd6b010c0d721ce57238e224..d519dcc5e08e1ff7a371c8c9e2fec18634d09ea0 100644 (file)
@@ -335,6 +335,7 @@ func runList(cmd *base.Command, args []string) {
                // Show vendor-expanded paths in listing
                p.TestImports = p.Resolve(p.TestImports)
                p.XTestImports = p.Resolve(p.XTestImports)
+               p.DepOnly = !cmdline[p]
        }
 
        if *listTest {