...

Text file src/cmd/go/testdata/script/mod_get_go_file.txt

Documentation: cmd/go/testdata/script

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

View as plain text