...
1# Test query for non-defaults in the env
2
3env GOROOT=./a
4env GOTOOLCHAIN=local
5env GOSUMDB=nodefault
6env GOPROXY=nodefault
7env GO111MODULE=auto
8env CGO_CFLAGS=nodefault
9env CGO_CPPFLAGS=nodefault
10
11go env -changed
12# linux output like GOTOOLCHAIN='local'
13# windows output like GOTOOLCHAIN=local
14stdout 'GOTOOLCHAIN=''?local''?'
15stdout 'GOSUMDB=''?nodefault''?'
16stdout 'GOPROXY=''?nodefault''?'
17stdout 'GO111MODULE=''?auto''?'
18stdout 'CGO_CFLAGS=''?nodefault''?'
19stdout 'CGO_CPPFLAGS=''?nodefault''?'
20
21go env -changed -json
22stdout '"GOTOOLCHAIN": "local"'
23stdout '"GOSUMDB": "nodefault"'
24stdout '"GOPROXY": "nodefault"'
25stdout '"GO111MODULE": "auto"'
26stdout '"CGO_CFLAGS": "nodefault"'
27stdout '"CGO_CPPFLAGS": "nodefault"'
28
29[GOOS:windows] env GOOS=linux
30[!GOOS:windows] env GOOS=windows
31[GOARCH:amd64] env GOARCH=arm64
32[!GOARCH:amd64] env GOARCH=amd64
33
34go env -changed GOOS
35[GOOS:windows] stdout 'set GOOS=linux'
36[!GOOS:windows] stdout 'GOOS=''windows'''
37go env -changed GOARCH
38[GOARCH:amd64] stdout 'set GOARCH=arm64|GOARCH=''arm64'''
39[!GOARCH:amd64] stdout 'set GOARCH=amd64|GOARCH=''amd64'''
40
41go env -changed -json GOOS
42[GOOS:windows] stdout '"GOOS": "linux"'
43[!GOOS:windows] stdout '"GOOS": "windows"'
44go env -changed -json GOARCH
45[GOARCH:amd64] stdout '"GOARCH": "arm64"'
46[!GOARCH:amd64] stdout '"GOARCH": "amd64"'
47
48env GOPROXY=s
49go env -changed GOPROXY
50! stdout 'GOPROXY'
51env GOPROXY=s2
52go env -changed GOPROXY
53stdout 'GOPROXY=''?s2''?'
54
55env GOROOT=./b
56go env -changed
57! stdout 'GOTOOLCHAIN=''?local''?'
58
59-- a/go.env --
60GOPROXY=s
61
62-- b/go.env --
63GOTOOLCHAIN=local
View as plain text