# Test query for non-defaults in the env

env GOROOT=./a
env GOTOOLCHAIN=local
env GOSUMDB=nodefault
env GOPROXY=nodefault
env GO111MODULE=auto
env CGO_CFLAGS=nodefault
env CGO_CPPFLAGS=nodefault

go env -changed
# linux output like GOTOOLCHAIN='local'
# windows output like GOTOOLCHAIN=local
stdout 'GOTOOLCHAIN=''?local''?'
stdout 'GOSUMDB=''?nodefault''?'
stdout 'GOPROXY=''?nodefault''?'
stdout 'GO111MODULE=''?auto''?'
stdout 'CGO_CFLAGS=''?nodefault''?'
stdout 'CGO_CPPFLAGS=''?nodefault''?'

go env -changed -json
stdout '"GOTOOLCHAIN": "local"'
stdout '"GOSUMDB": "nodefault"'
stdout '"GOPROXY": "nodefault"'
stdout '"GO111MODULE": "auto"'
stdout '"CGO_CFLAGS": "nodefault"'
stdout '"CGO_CPPFLAGS": "nodefault"'

[GOOS:windows] env GOOS=linux
[!GOOS:windows] env GOOS=windows
[GOARCH:amd64] env GOARCH=arm64
[!GOARCH:amd64] env GOARCH=amd64

go env -changed GOOS
[GOOS:windows] stdout 'set GOOS=linux'
[!GOOS:windows] stdout 'GOOS=''windows'''
go env -changed GOARCH
[GOARCH:amd64] stdout 'set GOARCH=arm64|GOARCH=''arm64'''
[!GOARCH:amd64] stdout 'set GOARCH=amd64|GOARCH=''amd64'''

go env -changed -json GOOS
[GOOS:windows] stdout '"GOOS": "linux"'
[!GOOS:windows] stdout '"GOOS": "windows"'
go env -changed -json GOARCH
[GOARCH:amd64] stdout '"GOARCH": "arm64"'
[!GOARCH:amd64] stdout '"GOARCH": "amd64"'

env GOPROXY=s
go env -changed GOPROXY
! stdout 'GOPROXY'
env GOPROXY=s2
go env -changed GOPROXY
stdout 'GOPROXY=''?s2''?'

env GOROOT=./b
go env -changed
! stdout 'GOTOOLCHAIN=''?local''?'

--  a/go.env --
GOPROXY=s

--  b/go.env --
GOTOOLCHAIN=local
