github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/gopath_moved_repo.txt (about) 1 env GO111MODULE=off 2 3 # Test that 'go get -u' reports packages whose VCS configurations do not 4 # match their import paths. 5 6 [!net] skip 7 [short] skip 8 9 # We need to execute a custom Go program to break the config files. 10 # 11 # git will ask for a username and password when we run 'go get -d -f -u', 12 # so we also need to set GIT_ASKPASS. Conveniently, a single binary can 13 # perform both tasks! 14 15 go build -o replace.exe replace 16 env GIT_ASKPASS=$PWD/replace.exe 17 18 19 # Test that 'go get -u' reports moved git packages. 20 21 [exec:git] go get -d rsc.io/pdf 22 [exec:git] go get -d -u rsc.io/pdf 23 [exec:git] exec ./replace.exe pdf rsc.io/pdf/.git/config 24 25 [exec:git] ! go get -d -u rsc.io/pdf 26 [exec:git] stderr 'is a custom import path for' 27 [exec:git] ! go get -d -f -u rsc.io/pdf 28 [exec:git] stderr 'validating server certificate|[nN]ot [fF]ound' 29 30 31 # Test that 'go get -u' reports moved Mercurial packages. 32 33 [exec:hg] go get -d vcs-test.golang.org/go/custom-hg-hello 34 [exec:hg] go get -d -u vcs-test.golang.org/go/custom-hg-hello 35 [exec:hg] exec ./replace.exe custom-hg-hello vcs-test.golang.org/go/custom-hg-hello/.hg/hgrc 36 37 [exec:hg] ! go get -d -u vcs-test.golang.org/go/custom-hg-hello 38 [exec:hg] stderr 'is a custom import path for' 39 [exec:hg] ! go get -d -f -u vcs-test.golang.org/go/custom-hg-hello 40 [exec:hg] stderr 'validating server certificate|[nN]ot [fF]ound' 41 42 43 -- replace/replace.go -- 44 package main 45 46 import ( 47 "bytes" 48 "io/ioutil" 49 "log" 50 "os" 51 ) 52 53 func main() { 54 if len(os.Args) < 3 { 55 return 56 } 57 58 base := []byte(os.Args[1]) 59 path := os.Args[2] 60 data, err := ioutil.ReadFile(path) 61 if err != nil { 62 log.Fatal(err) 63 } 64 err = ioutil.WriteFile(path, bytes.ReplaceAll(data, base, append(base, "XXX"...)), 0644) 65 if err != nil { 66 log.Fatal(err) 67 } 68 }