Skip to content

cmd/go: 'go get […]/[email protected]' fails when the repo root contains the go.mod file for […]/v2 but no .go source files #34746

@bcmills

Description

@bcmills

My fix for #34383 was incomplete: it failed to take into account the possibility that the longest path for the module would be a *PackageNotInModuleError, in which case we should prefer the *PackageNotInModuleError over an unclassified error from a module with a shorter path.

A reproducer:

example.com$ gotip version
go version devel +cfe23204 Sun Oct 6 18:18:50 2019 +0000 linux/amd64

example.com$ GOPROXY=direct gotip get vcs-test.golang.org/git/empty-v2-without-v1.git/[email protected]
go: finding vcs-test.golang.org/git/empty-v2-without-v1.git v2.0.0
go get vcs-test.golang.org/git/empty-v2-without-v1.git/[email protected]: vcs-test.golang.org/git/[email protected]: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v2

CC @jayconrod

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions