github.com/megatontech/mynoteforgo@v0.0.0-20200507084910-5d0c6ea6e890/源码/cmd/go/testdata/script/mod_tidy_replace.txt (about) 1 env GO111MODULE=on 2 3 # golang.org/issue/30166: 'go mod tidy' should not crash if a replaced module is 4 # involved in a cycle. 5 cd cycle 6 env GOTRACEBACK=off 7 go mod tidy 8 cd .. 9 10 # From inside the module, 'go list -m all' should NOT include transitive 11 # requirements of modules that have been replaced. 12 go list -m all 13 stdout 'rsc.io/quote/v3 v3.0.0' 14 ! stdout 'rsc.io/sampler' 15 ! stdout 'golang.org/x/text' 16 17 # From outside the module, 'go list -m all' should include them. 18 cd outside 19 go list -m all 20 stdout 'rsc.io/quote/v3 v3.0.0' 21 stdout 'rsc.io/sampler v1.3.0' 22 stdout 'golang.org/x/text' 23 cd .. 24 25 # 'go list all' should add indirect requirements to satisfy the packages 26 # imported from replacement modules. 27 ! grep 'rsc.io/sampler' go.mod 28 ! grep 'golang.org/x/text' go.mod 29 go list all 30 grep 'rsc.io/sampler' go.mod 31 grep 'golang.org/x/text' go.mod 32 33 # 'go get' and 'go mod tidy' should follow the requirements of the replacements, 34 # not the originals, even if that results in a set of versions that are 35 # misleading or redundant without those replacements. 36 go get rsc.io/sampler@v1.2.0 37 go mod tidy 38 go list -m all 39 stdout 'rsc.io/quote/v3 v3.0.0' 40 stdout 'rsc.io/sampler v1.2.0' 41 stdout 'golang.org/x/text' 42 43 # The requirements seen from outside may be higher (or lower) 44 # than those seen from within the module. 45 grep 'rsc.io/sampler v1.2.0' go.mod 46 cd outside 47 go list -m all 48 stdout 'rsc.io/sampler v1.3.0' 49 50 -- go.mod -- 51 module example.com/tidy 52 53 require rsc.io/quote/v3 v3.0.0 54 replace rsc.io/quote/v3 => ./not-rsc.io/quote/v3 55 56 -- imports.go -- 57 package tidy 58 59 import _ "rsc.io/quote/v3" 60 61 -- outside/go.mod -- 62 module example.com/tidy/outside 63 64 require example.com/tidy v0.0.0 65 replace example.com/tidy => ./.. 66 67 -- not-rsc.io/quote/v3/go.mod -- 68 module not-rsc.io/quote/v3 69 70 // No requirements specified! 71 72 -- not-rsc.io/quote/v3/quote.go -- 73 package quote 74 75 import ( 76 _ "rsc.io/sampler" 77 _ "golang.org/x/text/language" 78 ) 79 80 -- cycle/go.mod -- 81 module golang.org/issue/30166 82 83 require ( 84 golang.org/issue/30166/a v0.0.0 85 golang.org/issue/30166/b v0.0.0 86 ) 87 88 replace ( 89 golang.org/issue/30166/a => ./a 90 golang.org/issue/30166/b => ./b 91 ) 92 -- cycle/cycle.go -- 93 package cycle 94 95 import ( 96 _ "golang.org/issue/30166/a" 97 _ "golang.org/issue/30166/b" 98 ) 99 -- cycle/a/a.go -- 100 package a 101 -- cycle/a/go.mod -- 102 module golang.org/issue/30166/a 103 104 require golang.org/issue/30166/b v0.0.0 105 -- cycle/b/b.go -- 106 package b 107 -- cycle/b/go.mod -- 108 module golang.org/issue/30166/b 109 110 require golang.org/issue/30166/a v0.0.0