Skip to content

Commit 131d7e0

Browse files
committed
cmd/go: set DepOnly on package when calling go list -deps
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> Reviewed-by: Russ Cox <[email protected]>
1 parent b111f3c commit 131d7e0

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/cmd/go/go_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,10 @@ func TestGoListTest(t *testing.T) {
19751975

19761976
tg.run("list", "-test", "runtime/cgo")
19771977
tg.grepStdout(`^runtime/cgo$`, "missing runtime/cgo")
1978+
1979+
tg.run("list", "-deps", "-f", "{{if .DepOnly}}{{.ImportPath}}{{end}}", "sort")
1980+
tg.grepStdout(`^reflect$`, "missing reflect")
1981+
tg.grepStdoutNot(`^sort`, "unexpected sort")
19781982
}
19791983

19801984
func TestGoListCgo(t *testing.T) {

src/cmd/go/internal/list/list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ func runList(cmd *base.Command, args []string) {
335335
// Show vendor-expanded paths in listing
336336
p.TestImports = p.Resolve(p.TestImports)
337337
p.XTestImports = p.Resolve(p.XTestImports)
338+
p.DepOnly = !cmdline[p]
338339
}
339340

340341
if *listTest {

0 commit comments

Comments
 (0)