| cp go.mod go.mod.old |
| go mod tidy |
| cmp go.mod go.mod.old |
| |
| # In Go 1.14 mode, 'go list -m all' includes modules needed by the |
| # transitive closure of tests of dependencies of tests of dependencies of …. |
| |
| go list -m all |
| stdout 'example.com/b v0.1.0' |
| stdout 'example.com/c v0.1.0' |
| cmp go.mod go.mod.old |
| |
| # 'go test' (or equivalent) of any such dependency, no matter how remote, does |
| # not update the go.mod file. |
| |
| go list all |
| stdout example.com/a/x |
| stdout example.com/b # Test dependency of example.com/a/x. |
| stdout example.com/c # Test dependency of example.com/b. |
| |
| go list -test -deps all |
| stdout example.com/b |
| stdout example.com/c |
| cmp go.mod go.mod.old |
| |
| [!short] go test example.com/a/x |
| [!short] cmp go.mod go.mod.old |
| |
| [!short] go test example.com/b |
| [!short] cmp go.mod go.mod.old |
| |
| # TODO(#36460): |
| |
| # After changing to 'go 1.15` uniformly, 'go list -m all' should prune out |
| # example.com/c, because it is not imported by any package (or test of a package) |
| # transitively imported by the main module. |
| # example.com/a/x is transitively imported, |
| # and example.com/b is needed in order to run 'go test example.com/a/x', |
| # but example.com/c is not needed because we don't expect the user to need to run |
| # 'go test example.com/b'. |
| |
| -- go.mod -- |
| module example.com/lazy |
| |
| go 1.14 |
| |
| require example.com/a v0.1.0 |
| |
| replace ( |
| example.com/a v0.1.0 => ./a |
| example.com/b v0.1.0 => ./b1 |
| example.com/b v0.2.0 => ./b2 |
| example.com/c v0.1.0 => ./c1 |
| example.com/c v0.2.0 => ./c2 |
| ) |
| -- lazy.go -- |
| package lazy |
| |
| import ( |
| _ "example.com/a/x" |
| ) |
| -- a/go.mod -- |
| module example.com/a |
| |
| go 1.14 |
| |
| require example.com/b v0.1.0 |
| -- a/x/x.go -- |
| package x |
| -- a/x/x_test.go -- |
| package x |
| |
| import ( |
| "testing" |
| |
| _ "example.com/b" |
| ) |
| |
| func TestUsingB(t *testing.T) { |
| // … |
| } |
| -- b1/go.mod -- |
| module example.com/b |
| |
| go 1.14 |
| |
| require example.com/c v0.1.0 |
| -- b1/b.go -- |
| package b |
| -- b1/b_test.go -- |
| package b |
| |
| import _ "example.com/c" |
| -- b2/go.mod -- |
| module example.com/b |
| |
| go 1.14 |
| |
| require example.com/c v0.1.0 |
| -- b2/b.go -- |
| package b |
| This file should not be used, so this syntax error should be ignored. |
| -- b2/b_test.go -- |
| package b |
| This file should not be used, so this syntax error should be ignored. |
| -- c1/go.mod -- |
| module example.com/c |
| |
| go 1.14 |
| -- c1/c.go -- |
| package c |
| -- c2/go.mod -- |
| module example.com/c |
| |
| go 1.14 |
| -- c2/c.go -- |
| package c |
| This file should not be used, so this syntax error should be ignored. |