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

     1  [!net] skip
     2  env GO111MODULE=off
     3  
     4  # Issue 4186. go get cannot be used to download packages to $GOROOT.
     5  # Test that without GOPATH set, go get should fail.
     6  
     7  # Fails because GOROOT=GOPATH
     8  env GOPATH=$WORK/tmp
     9  env GOROOT=$WORK/tmp
    10  ! go get -d github.com/golang/example/hello
    11  stderr 'warning: GOPATH set to GOROOT'
    12  stderr '\$GOPATH must not be set to \$GOROOT'
    13  
    14  # Fails because GOROOT=GOPATH after cleaning.
    15  env GOPATH=$WORK/tmp/
    16  env GOROOT=$WORK/tmp
    17  ! go get -d github.com/golang/example/hello
    18  stderr 'warning: GOPATH set to GOROOT'
    19  stderr '\$GOPATH must not be set to \$GOROOT'
    20  
    21  env GOPATH=$WORK/tmp
    22  env GOROOT=$WORK/tmp/
    23  ! go get -d github.com/golang/example/hello
    24  stderr 'warning: GOPATH set to GOROOT'
    25  stderr '\$GOPATH must not be set to \$GOROOT'
    26  
    27  # Make a home directory
    28  mkdir $WORK/home/go
    29  
    30  # Fails because GOROOT=$HOME/go so default GOPATH unset.
    31  [windows] env USERPROFILE=$WORK/home
    32  [plan9] env home=$WORK/home
    33  [!windows] [!plan9] env HOME=$WORK/home
    34  env GOPATH=
    35  env GOROOT=$WORK/home/go
    36  ! go get -d github.com/golang/example/hello
    37  stderr '\$GOPATH not set'
    38  
    39  [windows] env USERPROFILE=$WORK/home/
    40  [plan9] env home=$WORK/home/
    41  [!windows] [!plan9] env HOME=$WORK/home/
    42  env GOPATH=
    43  env GOROOT=$WORK/home/go
    44  ! go get -d github.com/golang/example/hello
    45  stderr '\$GOPATH not set'
    46  
    47  [windows] env USERPROFILE=$WORK/home
    48  [plan9] env home=$WORK/home
    49  [!windows] [!plan9] env HOME=$WORK/home
    50  env GOPATH=
    51  env GOROOT=$WORK/home/go/
    52  ! go get -d github.com/golang/example/hello
    53  stderr '\$GOPATH not set'
    54  

View as plain text