Description
#!/bin/bash
docker run -i golang:1.15beta1 <<-SCRIPT
set -ex
go version
go env
mkdir /tmp/foo
cd /tmp/foo
go mod init test
go get -d google.golang.org/protobuf || cat go.mod
SCRIPT
This fails:
+ go mod init test
go: creating new go.mod: module test
+ go get -d google.golang.org/protobuf
go: downloading google.golang.org/protobuf v1.25.0
go: google.golang.org/protobuf upgrade => v1.25.0
go get google.golang.org/protobuf: no Go source files
+ cat go.mod
module test
go 1.15
Happens on my local go version devel +4f2a2d7e26 Wed Jul 8 22:16:24 2020 +0000 linux/amd64
too.
Note the build-ignored test file at the root of the module: https://github.com/protocolbuffers/protobuf-go/blob/e14d6b3cdce27a8743907161e84fa6d07e30266d/integration_test.go
The script above succeeds if I use a module that has no Go files at its root, such as mvdan.cc/sh/v3
. For the time being, I've worked around the issue by manually editing go.mod
, and then go mod tidy
ensures it's OK and updates go.sum
.
This seems like a pretty straightforward bug, and I'm surprised it hasn't surfaced before, but I couldn't find a previous issue. Happy to attempt a fix if the bug can be confirmed - in that case, pointers for the fix would be appreciated. CC @jayconrod @bcmills @matloob