github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_tidy_replace.txt (about) 1 env GO111MODULE=on 2 [short] skip 3 4 # golang.org/issue/30166: 'go mod tidy' should not crash if a replaced module is 5 # involved in a cycle. 6 cd cycle 7 env GOTRACEBACK=off 8 go mod tidy 9 cd .. 10 11 # From inside the module, 'go list -m all' should NOT include transitive 12 # requirements of modules that have been replaced. 13 go list -m all 14 stdout 'rsc.io/quote/v3 v3.0.0' 15 ! stdout 'rsc.io/sampler' 16 ! stdout 'golang.org/x/text' 17 18 # From outside the module, 'go list -m all' should include them. 19 cd outside 20 go list -m all 21 stdout 'rsc.io/quote/v3 v3.0.0' 22 stdout 'rsc.io/sampler v1.3.0' 23 stdout 'golang.org/x/text' 24 cd .. 25 26 # 'go list all' should add indirect requirements to satisfy the packages 27 # imported from replacement modules. 28 ! grep 'rsc.io/sampler' go.mod 29 ! grep 'golang.org/x/text' go.mod 30 go list all 31 grep 'rsc.io/sampler' go.mod 32 grep 'golang.org/x/text' go.mod 33 34 # 'go get' and 'go mod tidy' should follow the requirements of the replacements, 35 # not the originals, even if that results in a set of versions that are 36 # misleading or redundant without those replacements. 37 go get rsc.io/sampler@v1.2.0 38 go mod tidy 39 go list -m all 40 stdout 'rsc.io/quote/v3 v3.0.0' 41 stdout 'rsc.io/sampler v1.2.0' 42 stdout 'golang.org/x/text' 43 44 # The requirements seen from outside may be higher (or lower) 45 # than those seen from within the module. 46 grep 'rsc.io/sampler v1.2.0' go.mod 47 cd outside 48 go list -m all 49 stdout 'rsc.io/sampler v1.3.0' 50 cd .. 51 52 # The same module can't be used as two different paths. 53 cd multiple-paths 54 ! go mod tidy 55 stderr 'rsc.io/quote/v3@v3.0.0 used for two different module paths \(not-rsc.io/quote/v3 and rsc.io/quote/v3\)' 56 57 -- go.mod -- 58 module example.com/tidy 59 60 require rsc.io/quote/v3 v3.0.0 61 replace rsc.io/quote/v3 => ./not-rsc.io/quote/v3 62 63 -- imports.go -- 64 package tidy 65 66 import _ "rsc.io/quote/v3" 67 68 -- outside/go.mod -- 69 module example.com/tidy/outside 70 71 require example.com/tidy v0.0.0 72 replace example.com/tidy => ./.. 73 74 -- not-rsc.io/quote/v3/go.mod -- 75 module not-rsc.io/quote/v3 76 77 // No requirements specified! 78 79 -- not-rsc.io/quote/v3/quote.go -- 80 package quote 81 82 import ( 83 _ "rsc.io/sampler" 84 _ "golang.org/x/text/language" 85 ) 86 87 -- cycle/go.mod -- 88 module golang.org/issue/30166 89 90 require ( 91 golang.org/issue/30166/a v0.0.0 92 golang.org/issue/30166/b v0.0.0 93 ) 94 95 replace ( 96 golang.org/issue/30166/a => ./a 97 golang.org/issue/30166/b => ./b 98 ) 99 -- cycle/cycle.go -- 100 package cycle 101 102 import ( 103 _ "golang.org/issue/30166/a" 104 _ "golang.org/issue/30166/b" 105 ) 106 -- cycle/a/a.go -- 107 package a 108 -- cycle/a/go.mod -- 109 module golang.org/issue/30166/a 110 111 require golang.org/issue/30166/b v0.0.0 112 -- cycle/b/b.go -- 113 package b 114 -- cycle/b/go.mod -- 115 module golang.org/issue/30166/b 116 117 require golang.org/issue/30166/a v0.0.0 118 -- multiple-paths/main.go -- 119 package main 120 121 import ( 122 "fmt" 123 "rsc.io/quote/v3" 124 ) 125 126 func main() { 127 fmt.Println(quote.GoV3()) 128 } 129 -- multiple-paths/go.mod -- 130 module quoter 131 132 require ( 133 rsc.io/quote/v3 v3.0.0 134 not-rsc.io/quote/v3 v3.0.0 135 ) 136 137 replace not-rsc.io/quote/v3 => rsc.io/quote/v3 v3.0.0