github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/go/testdata/script/env_write.txt (about) 1 env GO111MODULE=off 2 3 # go env should default to the right places 4 env AppData=$HOME/windowsappdata 5 env home=$HOME/plan9home 6 go env GOENV 7 [aix] stdout $HOME/.config/go/env 8 [darwin] stdout $HOME'/Library/Application Support/go/env' 9 [freebsd] stdout $HOME/.config/go/env 10 [linux] stdout $HOME/.config/go/env 11 [netbsd] stdout $HOME/.config/go/env 12 [openbsd] stdout $HOME/.config/go/env 13 [plan9] stdout $HOME/plan9home/lib/go/env 14 [windows] stdout $HOME\\windowsappdata\\go\\env 15 16 # Now override it to something writable. 17 env GOENV=$WORK/envdir/go/env 18 go env GOENV 19 stdout envdir[\\/]go[\\/]env 20 21 # go env shows all variables 22 go env 23 stdout GOARCH= 24 stdout GOOS= 25 stdout GOROOT= 26 27 # go env -w changes default setting 28 env root= 29 [windows] env root=c: 30 env GOPATH= 31 go env -w GOPATH=$root/non-exist/gopath 32 ! stderr .+ 33 grep GOPATH=$root/non-exist/gopath $WORK/envdir/go/env 34 go env GOPATH 35 stdout /non-exist/gopath 36 37 # go env -w does not override OS environment, and warns about that 38 env GOPATH=$root/other 39 go env -w GOPATH=$root/non-exist/gopath2 40 stderr 'warning: go env -w GOPATH=... does not override conflicting OS environment variable' 41 go env GOPATH 42 stdout $root/other 43 44 # but go env -w does do the update, and unsetting the env var exposes the change 45 env GOPATH= 46 go env GOPATH 47 stdout $root/non-exist/gopath2 48 49 # unsetting with go env -u does not warn about OS environment overrides, 50 # nor does it warn about variables that haven't been set by go env -w. 51 env GOPATH=$root/other 52 go env -u GOPATH 53 ! stderr .+ 54 go env -u GOPATH 55 ! stderr .+ 56 57 # go env -w rejects unknown or bad variables 58 ! go env -w GODEBUG=gctrace=1 59 stderr 'unknown go command variable GODEBUG' 60 ! go env -w GOEXE=.bat 61 stderr 'GOEXE cannot be modified' 62 ! go env -w GOENV=/env 63 stderr 'GOENV can only be set using the OS environment' 64 65 # go env -w can set multiple variables 66 env CC= 67 go env CC 68 ! stdout ^xyc$ 69 go env -w GOOS=$GOOS CC=xyc 70 grep CC=xyc $GOENV 71 # file is maintained in sorted order 72 grep 'CC=xyc\nGOOS=' $GOENV 73 go env CC 74 stdout ^xyc$ 75 76 # go env -u unsets effect of go env -w. 77 go env -u CC 78 go env CC 79 ! stdout ^xyc$ 80 81 # go env -w rejects double-set variables 82 ! go env -w GOOS=$GOOS GOOS=$GOOS 83 stderr 'multiple values for key: GOOS' 84 85 # go env -w rejects missing variables 86 ! go env -w GOOS 87 stderr 'arguments must be KEY=VALUE: invalid argument: GOOS' 88 89 # go env -w rejects invalid GO111MODULE values, as otherwise cmd/go would break 90 ! go env -w GO111MODULE=badvalue 91 stderr 'invalid GO111MODULE value "badvalue"' 92 93 # go env -w rejects invalid GOPATH values 94 ! go env -w GOPATH=~/go 95 stderr 'GOPATH entry cannot start with shell metacharacter' 96 97 ! go env -w GOPATH=./go 98 stderr 'GOPATH entry is relative; must be absolute path' 99 100 # go env -w/-u checks validity of GOOS/ARCH combinations 101 env GOOS= 102 env GOARCH= 103 # check -w doesn't allow invalid GOOS 104 ! go env -w GOOS=linuxx 105 stderr 'unsupported GOOS/GOARCH pair linuxx' 106 # check -w doesn't allow invalid GOARCH 107 ! go env -w GOARCH=amd644 108 stderr 'unsupported GOOS/GOARCH.*/amd644$' 109 # check -w doesn't allow invalid GOOS with valid GOARCH 110 ! go env -w GOOS=linuxx GOARCH=amd64 111 stderr 'unsupported GOOS/GOARCH pair linuxx' 112 # check a valid GOOS and GOARCH values but an incompatible combinations 113 ! go env -w GOOS=android GOARCH=s390x 114 stderr 'unsupported GOOS/GOARCH pair android/s390x' 115 # check that -u considers explicit envs 116 go env -w GOOS=linux GOARCH=mips 117 env GOOS=windows 118 ! go env -u GOOS 119 stderr 'unsupported GOOS/GOARCH.*windows/mips$'