github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/gopath_local.txt (about) 1 env GO111MODULE=off # Relative imports only work in GOPATH mode. 2 3 [short] skip 4 5 # Imports should be resolved relative to the source file. 6 go build testdata/local/easy.go 7 exec ./easy$GOEXE 8 stdout '^easysub\.Hello' 9 10 # Ignored files should be able to import the package built from 11 # non-ignored files in the same directory. 12 go build -o easysub$GOEXE testdata/local/easysub/main.go 13 exec ./easysub$GOEXE 14 stdout '^easysub\.Hello' 15 16 # Files in relative-imported packages should be able to 17 # use relative imports themselves. 18 go build testdata/local/hard.go 19 exec ./hard$GOEXE 20 stdout '^sub\.Hello' 21 22 # Explicit source files listed on the command line should not install without 23 # GOBIN set, since individual source files aren't part of the containing GOPATH. 24 ! go install testdata/local/easy.go 25 stderr '^go install: no install location for \.go files listed on command line \(GOBIN not set\)$' 26 27 [windows] stop # Windows does not allow the ridiculous directory name we're about to use. 28 29 env BAD_DIR_NAME='#$%:, &()*;<=>?\^{}' 30 31 mkdir -p testdata/$BAD_DIR_NAME/easysub 32 mkdir -p testdata/$BAD_DIR_NAME/sub/sub 33 34 cp testdata/local/easy.go testdata/$BAD_DIR_NAME/easy.go 35 cp testdata/local/easysub/easysub.go testdata/$BAD_DIR_NAME/easysub/easysub.go 36 cp testdata/local/easysub/main.go testdata/$BAD_DIR_NAME/easysub/main.go 37 cp testdata/local/hard.go testdata/$BAD_DIR_NAME/hard.go 38 cp testdata/local/sub/sub.go testdata/$BAD_DIR_NAME/sub/sub.go 39 cp testdata/local/sub/sub/subsub.go testdata/$BAD_DIR_NAME/sub/sub/subsub.go 40 41 # Imports should be resolved relative to the source file. 42 go build testdata/$BAD_DIR_NAME/easy.go 43 exec ./easy$GOEXE 44 stdout '^easysub\.Hello' 45 46 # Ignored files should be able to import the package built from 47 # non-ignored files in the same directory. 48 go build -o easysub$GOEXE testdata/$BAD_DIR_NAME/easysub/main.go 49 exec ./easysub$GOEXE 50 stdout '^easysub\.Hello' 51 52 # Files in relative-imported packages should be able to 53 # use relative imports themselves. 54 go build testdata/$BAD_DIR_NAME/hard.go 55 exec ./hard$GOEXE 56 stdout '^sub\.Hello' 57 58 # Explicit source files listed on the command line should not install without 59 # GOBIN set, since individual source files aren't part of the containing GOPATH. 60 ! go install testdata/$BAD_DIR_NAME/easy.go 61 stderr '^go install: no install location for \.go files listed on command line \(GOBIN not set\)$' 62 63 -- testdata/local/easy.go -- 64 package main 65 66 import "./easysub" 67 68 func main() { 69 easysub.Hello() 70 } 71 -- testdata/local/easysub/easysub.go -- 72 package easysub 73 74 import "fmt" 75 76 func Hello() { 77 fmt.Println("easysub.Hello") 78 } 79 -- testdata/local/easysub/main.go -- 80 // +build ignore 81 82 package main 83 84 import "." 85 86 func main() { 87 easysub.Hello() 88 } 89 -- testdata/local/hard.go -- 90 package main 91 92 import "./sub" 93 94 func main() { 95 sub.Hello() 96 } 97 -- testdata/local/sub/sub.go -- 98 package sub 99 100 import ( 101 "fmt" 102 103 subsub "./sub" 104 ) 105 106 func Hello() { 107 fmt.Println("sub.Hello") 108 subsub.Hello() 109 } 110 -- testdata/local/sub/sub/subsub.go -- 111 package subsub 112 113 import "fmt" 114 115 func Hello() { 116 fmt.Println("subsub.Hello") 117 }