1 # Tests Issue #38478
2 # Tests that go get in GOPATH mode returns a specific error if the argument
3 # ends with '.go', and either has no slash or refers to an existing file.
4
5 env GO111MODULE=off
6
7 # argument doesn't have .go suffix
8 go get -d test
9
10 # argument has .go suffix, is a file and exists
11 ! go get -d test.go
12 stderr 'go: test.go: arguments must be package or module paths'
13
14 # argument has .go suffix, doesn't exist and has no slashes
15 ! go get -d test_missing.go
16 stderr 'go: test_missing.go: arguments must be package or module paths'
17
18 # argument has .go suffix, is a file and exists in sub-directory
19 ! go get -d test/test.go
20 stderr 'go: test/test.go exists as a file, but ''go get'' requires package arguments'
21
22 # argument has .go suffix, doesn't exist and has slashes
23 ! go get -d test/test_missing.go
24 ! stderr 'arguments must be package or module paths'
25 ! stderr 'exists as a file, but ''go get'' requires package arguments'
26
27 # argument has .go suffix, is a symlink and exists
28 [symlink] symlink test_sym.go -> test.go
29 [symlink] ! go get -d test_sym.go
30 [symlink] stderr 'go: test_sym.go: arguments must be package or module paths'
31 [symlink] rm test_sym.go
32
33 # argument has .go suffix, is a symlink and exists in sub-directory
34 [symlink] symlink test/test_sym.go -> test.go
35 [symlink] ! go get -d test/test_sym.go
36 [symlink] stderr 'go: test/test_sym.go exists as a file, but ''go get'' requires package arguments'
37 [symlink] rm test_sym.go
38
39 # argument has .go suffix, is a directory and exists
40 mkdir test_dir.go
41 ! go get -d test_dir.go
42 stderr 'go: test_dir.go: arguments must be package or module paths'
43 rm test_dir.go
44
45 # argument has .go suffix, is a directory and exists in sub-directory
46 mkdir test/test_dir.go
47 ! go get -d test/test_dir.go
48 ! stderr 'arguments must be package or module paths'
49 ! stderr 'exists as a file, but ''go get'' requires package arguments'
50 rm test/test_dir.go
51
52
53 -- test.go --
54 package main
55 func main() {println("test")}
56
57
58 -- test/test.go --
59 package main
60 func main() {println("test")}
61
View as plain text