github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_load_badchain.txt (about) 1 [short] skip 2 env GO111MODULE=on 3 4 # Download everything to avoid "finding" messages in stderr later. 5 cp go.mod.orig go.mod 6 go mod download 7 go mod download example.com@v1.0.0 8 go mod download example.com/badchain/a@v1.1.0 9 go mod download example.com/badchain/b@v1.1.0 10 go mod download example.com/badchain/c@v1.1.0 11 12 # Try to update example.com/badchain/a (and its dependencies). 13 ! go get -d example.com/badchain/a 14 cmp stderr update-a-expected 15 cmp go.mod go.mod.orig 16 17 # Try to update the main module. This updates everything, including 18 # modules that aren't direct requirements, so the error stack is shorter. 19 ! go get -d -u ./... 20 cmp stderr update-main-expected 21 cmp go.mod go.mod.orig 22 23 # Update manually. Listing modules should produce an error. 24 go mod edit -require=example.com/badchain/a@v1.1.0 25 ! go list -m 26 cmp stderr list-expected 27 28 # Try listing a package that imports a package 29 # in a module without a requirement. 30 go mod edit -droprequire example.com/badchain/a 31 ! go list m/use 32 cmp stderr list-missing-expected 33 34 ! go list -test m/testuse 35 cmp stderr list-missing-test-expected 36 37 -- go.mod.orig -- 38 module m 39 40 go 1.13 41 42 require example.com/badchain/a v1.0.0 43 -- use/use.go -- 44 package use 45 46 import _ "example.com/badchain/c" 47 -- testuse/testuse.go -- 48 package testuse 49 -- testuse/testuse_test.go -- 50 package testuse 51 52 import ( 53 "testing" 54 _ "example.com/badchain/c" 55 ) 56 57 func Test(t *testing.T) {} 58 -- update-main-expected -- 59 go: example.com/badchain/c upgrade => v1.1.0 60 go get: example.com/badchain/c@v1.0.0 updating to 61 example.com/badchain/c@v1.1.0: parsing go.mod: 62 module declares its path as: badchain.example.com/c 63 but was required as: example.com/badchain/c 64 -- update-a-expected -- 65 go: example.com/badchain/a upgrade => v1.1.0 66 go get: example.com/badchain/a@v1.1.0 requires 67 example.com/badchain/b@v1.1.0 requires 68 example.com/badchain/c@v1.1.0: parsing go.mod: 69 module declares its path as: badchain.example.com/c 70 but was required as: example.com/badchain/c 71 -- list-expected -- 72 go: example.com/badchain/a@v1.1.0 requires 73 example.com/badchain/b@v1.1.0 requires 74 example.com/badchain/c@v1.1.0: parsing go.mod: 75 module declares its path as: badchain.example.com/c 76 but was required as: example.com/badchain/c 77 -- list-missing-expected -- 78 go: finding module for package example.com/badchain/c 79 go: found example.com/badchain/c in example.com/badchain/c v1.1.0 80 go: m/use imports 81 example.com/badchain/c: example.com/badchain/c@v1.1.0: parsing go.mod: 82 module declares its path as: badchain.example.com/c 83 but was required as: example.com/badchain/c 84 -- list-missing-test-expected -- 85 go: finding module for package example.com/badchain/c 86 go: found example.com/badchain/c in example.com/badchain/c v1.1.0 87 go: m/testuse tested by 88 m/testuse.test imports 89 example.com/badchain/c: example.com/badchain/c@v1.1.0: parsing go.mod: 90 module declares its path as: badchain.example.com/c 91 but was required as: example.com/badchain/c