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 env GOFIPS140=latest
11
12 go env -changed
13 # linux output like GOTOOLCHAIN='local'
14 # windows output like GOTOOLCHAIN=local
15 stdout 'GOTOOLCHAIN=''?local''?'
16 stdout 'GOSUMDB=''?nodefault''?'
17 stdout 'GOPROXY=''?nodefault''?'
18 stdout 'GO111MODULE=''?auto''?'
19 stdout 'CGO_CFLAGS=''?nodefault''?'
20 stdout 'CGO_CPPFLAGS=''?nodefault''?'
21 stdout 'GOFIPS140=''?latest''?'
22
23 go env -changed -json
24 stdout '"GOTOOLCHAIN": "local"'
25 stdout '"GOSUMDB": "nodefault"'
26 stdout '"GOPROXY": "nodefault"'
27 stdout '"GO111MODULE": "auto"'
28 stdout '"CGO_CFLAGS": "nodefault"'
29 stdout '"CGO_CPPFLAGS": "nodefault"'
30 stdout '"GOFIPS140": "latest"'
31
32 [GOOS:windows] env GOOS=linux
33 [!GOOS:windows] env GOOS=windows
34 [GOARCH:amd64] env GOARCH=arm64
35 [!GOARCH:amd64] env GOARCH=amd64
36
37 go env -changed GOOS
38 [GOOS:windows] stdout 'set GOOS=linux'
39 [!GOOS:windows] stdout 'GOOS=''windows'''
40 go env -changed GOARCH
41 [GOARCH:amd64] stdout 'set GOARCH=arm64|GOARCH=''arm64'''
42 [!GOARCH:amd64] stdout 'set GOARCH=amd64|GOARCH=''amd64'''
43
44 go env -changed -json GOOS
45 [GOOS:windows] stdout '"GOOS": "linux"'
46 [!GOOS:windows] stdout '"GOOS": "windows"'
47 go env -changed -json GOARCH
48 [GOARCH:amd64] stdout '"GOARCH": "arm64"'
49 [!GOARCH:amd64] stdout '"GOARCH": "amd64"'
50
51 env GOARCH=amd64
52 env GOAMD64=v3
53 go env -changed
54 stdout 'GOAMD64=''?v3''?'
55
56 env GOPROXY=s
57 go env -changed GOPROXY
58 ! stdout 'GOPROXY'
59 env GOPROXY=s2
60 go env -changed GOPROXY
61 stdout 'GOPROXY=''?s2''?'
62
63 env GOROOT=./b
64 go env -changed
65 ! stdout 'GOTOOLCHAIN=''?local''?'
66
67 -- a/go.env --
68 GOPROXY=s
69 GOAMD64=v1
70 GOFIPS140=off
71
72 -- b/go.env --
73 GOTOOLCHAIN=local
74
View as plain text