-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Description
Go version
go version go1.23.2 linux/amd64
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/opt/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/opt/go/'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.2'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build345801054=/tmp/go-build -gno-record-gcc-switches'
What did you do?
Downloaded tar from golang website, tar -xvf in /opt.
Now
i) GOPATH="/opt/go"
ii) GOROOT="/opt/go"
Then, install any go program
go install github.com/go-acme/lego/v4/cmd/lego@latest
It will be downloaded in /opt/go/pkg cleanly which is desirable but also splits out warning
warning: GOPATH set to GOROOT (/opt/go/) has no effect
but installs go program cleanly.
Now change env to
GOROOT="/opt/go"
GOPATH="/opt/go/pkg"
Then it will unnecessarily create /opt/go/pkg/pkg instead of just using /opt/go/pkg similar to when GOPATH==GOROOT. I am trying to avoid warning of GOPATH==GOROOT but at the same time its unnecessarily creating extra /opt/go/pkg/pkg folder.
What did you see happen?
Extra pkg directory /opt/go/pkg/pkg
What did you expect to see?
No extra pkg directory. Simply install in /opt/go/pkg