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: suppress errors for 'go get' of package paths whose source files are all excluded by build constraints #33526

Open
jadekler opened this issue Aug 7, 2019 · 1 comment

Comments

@jadekler
Copy link
Contributor

@jadekler jadekler commented Aug 7, 2019

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

$ go version
go version go1.13beta1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/deklerk/Library/Caches/go-build"
GOENV="/Users/deklerk/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/deklerk/workspace/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/tmp/foo/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/c2/cvxltzcd66v5lx14hm1j76q000h16k/T/go-build777475143=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

deklerk at deklerk-macbookpro2 in /tmp/foo
$ go get google.golang.org/genproto@v0.0.0-20190801165951-fa694d86fc64
go: downloading golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961
go: downloading golang.org/x/tools v0.0.0-20190226205152-f727befe758c
go: downloading honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099
go: extracting honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099
go: extracting golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961
go: extracting golang.org/x/tools v0.0.0-20190226205152-f727befe758c
can't load package: package google.golang.org/genproto: build constraints exclude all Go files in /Users/deklerk/workspace/go/pkg/mod/google.golang.org/genproto@v0.0.0-20190801165951-fa694d86fc64
deklerk at deklerk-macbookpro2 in /tmp/foo

What did you expect to see?

deklerk at deklerk-macbookpro2 in /tmp/foo
$ go get google.golang.org/genproto/...
go: downloading golang.org/x/sys v0.0.0-20180830151530-49385e6e1522
go: extracting golang.org/x/sys v0.0.0-20180830151530-49385e6e1522
go: finding google.golang.org/genproto latest
deklerk at deklerk-macbookpro2 in /tmp/foo

What did you see instead?

(see above)

TLDR genproto has a build constraint at the root (+tools, nothing else at root), but many packages below the root do not have this build constraint. When I use go get in module mode - esp when I provide a version - I expect to only interact with the module system. Instead, it's a weird mix of module and package, and in this case though I wanted to get a module it gave me an error about a package of the same name.

@bcmills bcmills changed the title go get in module mode does build constraint checking cmd/go: go get in module mode does build constraint checking Aug 7, 2019
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Aug 7, 2019

go get requests to build a binary. If you know that what you want is just the module (and not the binary at the root of that module), go get -d informs the go command that it should stop without attempting to build such a binary.

It may be that we should suppress the error without -d anyway, though. (See #29268, which is very closely related.)

@bcmills bcmills added this to the Go1.14 milestone Aug 7, 2019
@bcmills bcmills changed the title cmd/go: go get in module mode does build constraint checking cmd/go: suppress errors for 'go get' of package paths whose source files are all excluded by build constraints Sep 17, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.