Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I want GOPATH==GOROOT effect without creating extra directory #69810

Closed
neochine opened this issue Oct 8, 2024 · 3 comments
Closed

I want GOPATH==GOROOT effect without creating extra directory #69810

neochine opened this issue Oct 8, 2024 · 3 comments

Comments

@neochine
Copy link

neochine commented Oct 8, 2024

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

@neochine
Copy link
Author

neochine commented Oct 8, 2024

I wanted behaviour of /opt/go/pkg/mod/github.com being added packages when GOROOT="/opt/go" AND GOPATH="/opt/go/pkg" but when i add that it causes /opt/go/pkg/pkg/mod/github.com

Having no GOPATH creates /root/go folder which is also undesirable

@seankhliao
Copy link
Member

I believe the separation is intentional, see also GOMODCACHE.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants