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: 'get -d' failing on modules with only a build-ignored Go file in their root directory #40145

Closed
mvdan opened this issue Jul 10, 2020 · 2 comments
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@mvdan
Copy link
Member

mvdan commented Jul 10, 2020

#!/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

@mvdan mvdan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go modules labels Jul 10, 2020
@jayconrod
Copy link
Contributor

I think #33526 is a duplicate of this issue, though the situation you describe seems more serious. I left a comment on that issue and milestoned it for 1.16.

@mvdan
Copy link
Member Author

mvdan commented Jul 10, 2020

Thanks, that makes sense! I tried to find that existing bug, but failed :)

@golang golang locked and limited conversation to collaborators Jul 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go modules 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

3 participants