Go version
go version go1.25.0 darwin/arm64
Output of go env
in your module/workspace:
AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/gianluca/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/gianluca/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/v0/wb8c7t0s3tx18hd66mx3sx3h0000gn/T/go-build3334334172=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='PRIVATE_REPOSITORY/MODULE/go.mod'
GOMODCACHE='/Users/gianluca/go/pkg/mod'
GONOPROXY='PRIVATE_GITLAB'
GONOSUMDB='PRIVATE_GITLAB'
GOOS='darwin'
GOPATH='/Users/gianluca/go'
GOPRIVATE='PRIVATE_GITLAB'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/gianluca/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.0'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
In repository .git/config
and $HOME/.gitconfig
:
[url "ssh://git@PRIVATE_GITLAB/"]
insteadOf = https://PRIVATE_GITLAB/
insteadOf = http://PRIVATE_GITLAB/
I run go mod tidy -x -v
inside repository nested module.
What did you see happen?
$ go mod tidy -x -v
go: finding module for package PRIVATE_GITLAB/PRIVATE_PROJECT/PRIVATE_REPOSITORY/pkg/utils
# get https://PRIVATE_GITLAB/?go-get=1
# get https://PRIVATE_GITLAB/PRIVATE_PROJECT/PRIVATE_REPOSITORY/pkg?go-get=1
# get https://PRIVATE_GITLAB/PRIVATE_PROJECT/PRIVATE_REPOSITORY/pkg/utils?go-get=1
# get https://PRIVATE_GITLAB/PRIVATE_PROJECT/PRIVATE_REPOSITORY?go-get=1
# get https://PRIVATE_GITLAB/PRIVATE_PROJECT?go-get=1
What did you expect to see?
I expect to see SSH protocol be used over HTTPS or HTTP but it still tries HTTPS after both gitconfig are configured
Comment From: gabyhelp
Related Issues
- cmd/go: `go mod tidy` not using `.git/config` settings #65041 (closed)
- cmd/go: go mod not using sshcommand configured in ~/.gitconfig #71482 (closed)
- go mod: git setting "instead of" not work in go mod #34513 (closed)
- cmd/go: git VCS qualifier in module path uses git:// scheme #63845 (closed)
- cmd/go: get with GIT_CONFIG ignores env variable #42055 (closed)
- cmd/go/internal/modcmd: go.work local module fetching from remote by mistake #71055 (closed)
- cmd/go: go module with a private repo on specific port #38213 (closed)
- cmd/go: mod tidy fails when using go-import subDir #75016 (closed)
- cmd/go: mod download uses global gitconfig, should check project's gitconfig first #31802 (closed)
Related Discussions
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Comment From: seankhliao
This is before git cloning. It needs to be able to determine the correct root of the repository. See GOAUTH or set netrc.
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
For questions please refer to https://github.com/golang/go/wiki/Questions
Comment From: aculnaig
@seankhliao Can you elaborate ? I thought GOAUTH was not necessary since I am trying to use SSH protocol