github.com/zxy12/go_duplicate_112_new@v0.0.0-20200807091221-747231827200/src/cmd/go/testdata/script/mod_find.txt (about) 1 # Derive module path from import comment. 2 cd $WORK/x 3 exists x.go 4 go mod init 5 stderr 'module x' 6 7 # Import comment works even with CRLF line endings. 8 rm go.mod 9 addcrlf x.go 10 go mod init 11 stderr 'module x' 12 13 # go mod should die in GOPATH if modules are not enabled for GOPATH 14 cd $GOPATH/src/example.com/x/y 15 ! go mod init 16 stderr 'go: modules disabled inside GOPATH/src by GO111MODULE=auto; see ''go help modules''' 17 18 env GO111MODULE=on 19 20 # Derive module path from location inside GOPATH. 21 cd $GOPATH/src/example.com/x/y 22 go mod init 23 stderr 'module example.com/x/y$' 24 rm go.mod 25 26 # Module path from Godeps/Godeps.json overrides GOPATH. 27 cd $GOPATH/src/example.com/x/y/z 28 go mod init 29 stderr 'unexpected.com/z' 30 rm go.mod 31 32 # Empty directory outside GOPATH fails. 33 mkdir $WORK/empty 34 cd $WORK/empty 35 ! go mod init 36 stderr 'cannot determine module path for source directory' 37 rm go.mod 38 39 # Empty directory inside GOPATH/src uses location inside GOPATH. 40 mkdir $GOPATH/src/empty 41 cd $GOPATH/src/empty 42 go mod init 43 stderr 'empty' 44 rm go.mod 45 46 [!symlink] stop 47 48 # gplink1/src/empty where gopathlink -> GOPATH 49 symlink $WORK/gopathlink -> gopath 50 cd $WORK/gopathlink/src/empty 51 go mod init 52 rm go.mod 53 54 # GOPATH/src/link where link -> out of GOPATH 55 symlink $GOPATH/src/link -> $WORK/empty 56 cd $WORK/empty 57 ! go mod init 58 cd $GOPATH/src/link 59 go mod init 60 stderr link 61 rm go.mod 62 63 # GOPATH/src/empty where GOPATH itself is a symlink 64 env GOPATH=$WORK/gopathlink 65 cd $GOPATH/src/empty 66 go mod init 67 rm go.mod 68 cd $WORK/gopath/src/empty 69 go mod init 70 rm go.mod 71 72 # GOPATH/src/link where GOPATH and link are both symlinks 73 cd $GOPATH/src/link 74 go mod init 75 stderr link 76 rm go.mod 77 78 # Too hard: doesn't match unevaluated nor completely evaluated. (Only partially evaluated.) 79 # Whether this works depends on which OS we are running on. 80 # cd $WORK/gopath/src/link 81 # ! go mod init 82 83 -- $WORK/x/x.go -- 84 package x // import "x" 85 86 -- $GOPATH/src/example.com/x/y/y.go -- 87 package y 88 -- $GOPATH/src/example.com/x/y/z/z.go -- 89 package z 90 -- $GOPATH/src/example.com/x/y/z/Godeps/Godeps.json -- 91 {"ImportPath": "unexpected.com/z"}