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