-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
Go version
go version devel go1.24-8397de2241 2024-11-23 00:23:59 +0000 linux/amd64
Output of go env
in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='0'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v3'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/user/.cache/go-build'
GODEBUG=''
GOENV='/home/user/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS='-trimpath "-ldflags=-s -w" -vet=all'
GOGCCFLAGS='-fPIC -m64 -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build303055721=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/user/tmp/testrepo0901/go.mod'
GOMODCACHE='/home/user/.data/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/user/.data/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/user/sdk/gotip'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/home/user/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='path'
GOTOOLDIR='/home/user/sdk/gotip/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.24-8397de2241 2024-11-23 00:23:59 +0000'
GOWORK=''
PKG_CONFIG='pkg-config'
Explicitly set environment with go env -changed
:
CGO_ENABLED='0'
GOAMD64='v3'
GOFLAGS='-trimpath "-ldflags=-s -w" -vet=all'
GOTOOLCHAIN='path'
What did you do?
https://go.dev/play/p/Apul33WDA2L
With a tool that reads the environment, run it via run vs tool:
go run ./mytool > env.old
go tool mytool > env.new
diff env.old env.new
results:
1a2
> AR=ar
6a8
> CC=gcc
8a11
> CGO_ENABLED=0
12a16
> CXX=g++
20a25,26
> GCCGO=gccgo
> GCM_INTERACTIVE=never
22a29,30
> GIT_SSH_COMMAND=ssh -o ControlMaster=no -o BatchMode=yes
> GIT_TERMINAL_PROMPT=0
23a32,42
> GOAMD64=v3
> GOARCH=amd64
> GOAUTH=netrc
> GOCACHE=/home/user/.cache/go-build
> GOENV=/home/user/.config/go/env
> GOFIPS140=off
> GOFLAGS=-trimpath "-ldflags=-s -w" -vet=all
> GOHOSTARCH=amd64
> GOHOSTOS=linux
> GOMODCACHE=/home/user/.data/go/pkg/mod
> GOOS=linux
24a44
> GOPROXY=https://proxy.golang.org,direct
25a46,51
> GOSUMDB=sum.golang.org
> GOTELEMETRY=on
> GOTELEMETRYDIR=/home/user/.config/go/telemetry
> GOTOOLCHAIN=path
> GOTOOLDIR=/home/user/sdk/gotip/pkg/tool/linux_amd64
> GOVERSION=devel go1.24-8397de2241 2024-11-23 00:23:59 +0000
What did you see happen?
go related environment variables are all explicitly set
What did you expect to see?
go envs aren't set.
For context, I wanted to use https://github.com/ko-build/ko for building multi platform container images, however, it refuses to run due to conflicting configuration of single vs multiple target platforms:
$ go tool ko apply ./cmd/moo
Error: error creating builder: error setting up builder options: cannot use --platform or defaultPlatforms in .ko.yaml or env KO_DEFAULTPLATFORMS combined with GOOS="linux"
Metadata
Metadata
Assignees
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.