github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/mod_vendor_replace.txt (about) 1 env GO111MODULE=on 2 3 # Before vendoring, we expect to see the original directory. 4 go list -f '{{with .Module}}{{.Version}}{{end}} {{.Dir}}' rsc.io/quote/v3 5 stdout 'v3.0.0' 6 stdout '.*[/\\]not-rsc.io[/\\]quote[/\\]v3' 7 8 # Since all dependencies are replaced, 'go mod vendor' should not 9 # have to download anything from the network. 10 go mod vendor 11 ! stderr 'downloading' 12 ! stderr 'finding' 13 14 # After vendoring, we expect to see the replacement in the vendor directory, 15 # without attempting to look up the non-replaced version. 16 cmp vendor/rsc.io/quote/v3/quote.go local/not-rsc.io/quote/v3/quote.go 17 18 go list -mod=vendor -f '{{with .Module}}{{.Version}}{{end}} {{.Dir}}' rsc.io/quote/v3 19 stdout 'v3.0.0' 20 stdout '.*[/\\]vendor[/\\]rsc.io[/\\]quote[/\\]v3' 21 ! stderr 'finding' 22 ! stderr 'lookup disabled' 23 24 # 'go list' should provide the original replacement directory as the module's 25 # replacement path. 26 go list -mod=vendor -f '{{with .Module}}{{with .Replace}}{{.Path}}{{end}}{{end}}' rsc.io/quote/v3 27 stdout '.*[/\\]not-rsc.io[/\\]quote[/\\]v3' 28 29 # The same module can't be used as two different paths. 30 cd multiple-paths 31 ! go mod vendor 32 stderr 'rsc.io/quote/v3@v3.0.0 used for two different module paths \(not-rsc.io/quote/v3 and rsc.io/quote/v3\)' 33 34 -- go.mod -- 35 module example.com/replace 36 37 require rsc.io/quote/v3 v3.0.0 38 replace rsc.io/quote/v3 => ./local/not-rsc.io/quote/v3 39 40 -- imports.go -- 41 package replace 42 43 import _ "rsc.io/quote/v3" 44 45 -- local/not-rsc.io/quote/v3/go.mod -- 46 module not-rsc.io/quote/v3 47 48 -- local/not-rsc.io/quote/v3/quote.go -- 49 package quote 50 51 -- multiple-paths/main.go -- 52 package main 53 import ( 54 "fmt" 55 "rsc.io/quote/v3" 56 ) 57 func main() { 58 fmt.Println(quote.GoV3()) 59 } 60 -- multiple-paths/go.mod -- 61 module quoter 62 require ( 63 rsc.io/quote/v3 v3.0.0 64 not-rsc.io/quote/v3 v3.0.0 65 ) 66 replace not-rsc.io/quote/v3 => rsc.io/quote/v3 v3.0.0