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: go get behavior change in 1.16 #44615

Closed
codyoss opened this issue Feb 25, 2021 · 5 comments
Closed

cmd/go: go get behavior change in 1.16 #44615

codyoss opened this issue Feb 25, 2021 · 5 comments
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@codyoss
Copy link
Member

codyoss commented Feb 25, 2021

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

$ go version
go version go1.16 linux/amd64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build3498846833=/tmp/go-build -gno-record-gcc-switches"

What did you do?

root@e229e72fbc21:/go# mkdir /workspace
root@e229e72fbc21:/go# cd /workspace/
root@e229e72fbc21:/workspace# go mod init example.com/workspace
go: creating new go.mod: module example.com/workspace
root@e229e72fbc21:/workspace# go get google.golang.org/genproto
go: downloading google.golang.org/genproto v0.0.0-20210224155714-063164c882e6
go: downloading golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135
go: downloading github.com/golang/protobuf v1.4.1
go: downloading golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3
go: downloading google.golang.org/protobuf v1.24.0
google.golang.org/genproto: no Go source files
package google.golang.org/genproto: build constraints exclude all Go files in /go/pkg/mod/google.golang.org/genproto@v0.0.0-20210224155714-063164c882e6
root@e229e72fbc21:/workspace# cat go.mod
module example.com/workspace

go 1.16

What did you expect to see?

A go.mod file with the dependency declared

What did you see instead?

An empty go.mod

Extra

  • To get this to work now I needed to run the command go get -d:
root@e229e72fbc21:/workspace# go get -d google.golang.org/genproto
google.golang.org/genproto: no Go source files
go get: added google.golang.org/genproto v0.0.0-20210224155714-063164c882e6
root@e229e72fbc21:/workspace# cat go.mod
module example.com/workspace

go 1.16

require google.golang.org/genproto v0.0.0-20210224155714-063164c882e6 // indirect
  • genproto is likely different from many modules as it has no sources at the Root
  • This used to work in 1.15 and prior
@seankhliao seankhliao added GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 25, 2021
@bcmills
Copy link
Contributor

bcmills commented Feb 25, 2021

go get without -d “builds and installs the named packages”, as it has done for quite some time. (We're slowly phasing out that behavior, but it as of Go 1.16 the semantics are the same as ever; see #43684.) As a special case, if go get is passed a module path that is not a valid package path, it suppresses the error from the fact that there is no such package to build.

However google.golang.org/genproto is a valid package path when -tags=tools is set — it has a tools.go source file with a build constraint.

@bcmills
Copy link
Contributor

bcmills commented Feb 25, 2021

This used to work in 1.15 and prior

That does not appear to be the case:

$ go1.15.8 get google.golang.org/genproto@latest
go: downloading google.golang.org/genproto v0.0.0-20210224155714-063164c882e6
go: google.golang.org/genproto latest => v0.0.0-20210224155714-063164c882e6
go: downloading github.com/golang/protobuf v1.4.1
go: downloading golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3
go: downloading golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135
go: downloading google.golang.org/protobuf v1.24.0
package google.golang.org/genproto: build constraints exclude all Go files in /tmp/tmp.PF7Sr2Nd7r/.gopath/pkg/mod/google.golang.org/genproto@v0.0.0-20210224155714-063164c882e6

@bcmills
Copy link
Contributor

bcmills commented Feb 25, 2021

Duplicate of #33526

@bcmills bcmills marked this as a duplicate of #33526 Feb 25, 2021
@bcmills bcmills closed this as completed Feb 25, 2021
@codyoss
Copy link
Member Author

codyoss commented Feb 25, 2021

@bcmills That error message has been there true, but it is the behavior that changed:

root@f16365c890d8:/go# go version
go version go1.15 linux/amd64
root@f16365c890d8:/go# mkdir /workspace
root@f16365c890d8:/go# cd /workspace/
root@f16365c890d8:/workspace# go mod init example.com/workspace
go: creating new go.mod: module example.com/workspace
root@f16365c890d8:/workspace# go get google.golang.org/genproto
go: downloading google.golang.org/genproto v0.0.0-20210224155714-063164c882e6
go: google.golang.org/genproto upgrade => v0.0.0-20210224155714-063164c882e6
go: downloading golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3
go: downloading github.com/golang/protobuf v1.4.1
go: downloading golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135
go: downloading google.golang.org/protobuf v1.24.0
package google.golang.org/genproto: build constraints exclude all Go files in /go/pkg/mod/google.golang.org/genproto@v0.0.0-20210224155714-063164c882e6
root@f16365c890d8:/workspace# cat go.mod
module example.com/workspace

go 1.15

require google.golang.org/genproto v0.0.0-20210224155714-063164c882e6 // indirect

That error message appeared but the command used to update the dependency still. Now it does not.

I noticed this because we have a script that updates our genproto version daily for google-cloud-go but after switching to go1.16 it no longer bumped up the version when runnning go get ...

@bcmills
Copy link
Contributor

bcmills commented Feb 25, 2021

The fact that the go.mod file is not written if the overall go get command fails is an intentional consequence of CL 255970, part of the fix for #41315.

@golang golang locked and limited conversation to collaborators Feb 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants