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

cmd/go: in mod 'go get' some module's version taged not from master branch failed #36599

Closed
mozhata opened this issue Jan 16, 2020 · 4 comments
Closed

Comments

@mozhata
Copy link

@mozhata mozhata commented Jan 16, 2020

What version of Go are you using (go version)?

$ go version
go version go1.13.6 linux/amd64

Does this issue reproduce with the latest release?

not clear

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/me/.cache/go-build"
GOENV="/home/me/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY="git.mycompany.com/myproject/*"
GONOSUMDB="git.mycompany.com/myproject/*"
GOOS="linux"
GOPATH="/home/me/go"
GOPRIVATE="git.mycompany.com/myproject/*"
GOPROXY="https://goproxy.io"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/me/go/src/AI_Platform/demo-core/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build726039279=/tmp/go-build -gno-record-gcc-switches"

What did you do?

first step
I create a module git.mycompany.com/myproject/scaffold
and make a version v0.0.1 by git tag in dev branch
and make a version v1.1.0 in master branch
and push them to my company's gitlab

secod step
I create a projet which import my module git.mycompany.com/myproject/scaffold
run go mod init myproject at root dir

I try get v0.0.1 failed, but v1.1.0 success

What did you expect to see?

v0.0.1 and v1.1.0 supposed both success

What did you see instead?

go clean -modcache

$ go get -v git.mycompany.com/myproject/scaffold@v0.0.1
get "git.mycompany.com/myproject/scaffold": found meta tag get.metaImport{Prefix:"git.mycompany.com/myproject/scaffold", VCS:"git", RepoRoot:"https://git.mycompany.com/myproject/scaffold.git"} at //git.mycompany.com/myproject/scaffold?go-get=1
go: finding git.mycompany.com/myproject/scaffold v0.0.1
go get git.mycompany.com/myproject/scaffold@v0.0.1: disabled by GOPRIVATE/GONOPROXY

$ go get -v git.mycompany.com/myproject/scaffold@v1.1.0
get "git.mycompany.com/myproject/scaffold": found meta tag get.metaImport{Prefix:"git.mycompany.com/myproject/scaffold", VCS:"git", RepoRoot:"https://git.mycompany.com/myproject/scaffold.git"} at //git.mycompany.com/myproject/scaffold?go-get=1
go: finding git.mycompany.com/myproject/scaffold v1.1.0
go: downloading git.mycompany.com/myproject/scaffold v1.1.0
go: extracting git.mycompany.com/myproject/scaffold v1.1.0
@mozhata

This comment has been minimized.

Copy link
Author

@mozhata mozhata commented Jan 16, 2020

I'm not sure about it, guess it's due to difference branch

@jayconrod

This comment has been minimized.

Copy link
Contributor

@jayconrod jayconrod commented Jan 16, 2020

This error message indicates that the go command needs to fetch a particular version of module but has been configured not to.

go get git.mycompany.com/myproject/scaffold@v0.0.1: disabled by GOPRIVATE/GONOPROXY

It looks like GOPRIVATE="git.mycompany.com/myproject/*". This means the go command will not send requests for anything with the prefix git.mycompany.com/myproject to the sumdb or to any proxy.

However, GOPROXY="https://goproxy.io". This means the go command will only download modules from that proxy. It won't try to download modules from their origin repositories.

You may want to try setting GOPROXY=https://goproxy.io,direct. The direct tells the go command to fetch modules from their origin repositories if they're not available on earlier proxies or if proxies can't be used due to GONOPROXY / GOPRIVATE.

I'm not sure why v1.1.0 would be available and not v0.0.1 though. Neither should be available. Is it available on https://proxy.io? Maybe your repo switched from public to private at some point between when the versions were published?

Closing because this doesn't seem like a bug in the Go toolchain. The golang-nuts mailing list or the #modules channel on Slack are better places to get support.

@jayconrod jayconrod closed this Jan 16, 2020
@mozhata

This comment has been minimized.

Copy link
Author

@mozhata mozhata commented Jan 17, 2020

new update: I tag a new version v0.1.0 and dev branch which same to v0.0.1, and run go get for it success

and repush v0.0.1 but always failed to download it.
and I's sure my module is alway a private module.

another thing, In my mind set GOPRIVATE="git.mycompany.com/myproject/*" and GOPROXY="https://goproxy.io go tools should download module with git.mycompany.com/myproject directly

which should act as should act as GOPROXY=https://goproxy.io,direct
am I wrong ?

@jayconrod

This comment has been minimized.

Copy link
Contributor

@jayconrod jayconrod commented Jan 17, 2020

new update: I tag a new version v0.1.0 and dev branch which same to v0.0.1, and run go get for it success

and repush v0.0.1 but always failed to download it.
and I's sure my module is alway a private module.

We can't really tell what's going on without a complete example.

another thing, In my mind set GOPRIVATE="git.mycompany.com/myproject/*" and GOPROXY="https://goproxy.io go tools should download module with git.mycompany.com/myproject directly

which should act as should act as GOPROXY=https://goproxy.io,direct
am I wrong ?

It's important that there's a distinction between GOPROXY=https://goproxy.io and GOPROXY=https://goproxy.io,direct. They mean different things. go help module-private explains GOPRIVATE, GONOPROXY, and GONOSUMDB.

https://goproxy.io specifically recommends setting it up this way, too:

If your Go version >= 1.13, the GOPRIVATE environment variable controls which modules the go command considers to be private (not available publicly) and should therefore not use the proxy or checksum database. For example:

Go version >= 1.13
Copy
go env -w GOPROXY=https://goproxy.io,direct
# Set environment variable allow bypassing the proxy for selected modules
go env -w GOPRIVATE=*.corp.example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.