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