Skip to content

cmd/go/internal/modfetch: erroneously resolves a v2.…+incompatible version when a v2/go.mod file exists #51324

Description

@bcmills

CL 378400 appears to have introduced a regression for modules that contain a v2/go.mod file and not go.mod file at the repo root.

github.com/sacloud/libsacloud at commit b491c1c2c6bd6e18fd0b55ef6770ecd1e66f1419 is one such example.
At that revision, it contains a v2/go.mod file that correctly declares module github.com/sacloud/libsacloud/v2, and no go.mod file whatsoever at the module root. The corresponding v2 pseudo-version should therefore apply only to the v2 module (github.com/sacloud/libsacloud/v2) — it should not also be valid as a +incompatible version for the module at the root of the repo.

Go 1.17 as originally released correctly rejected that version for the repo root. go1.18rc1 does not.

$ export GOPRIVATE=github.com/sacloud/libsacloud

$ go clean -modcache

$ gotip list -m github.com/sacloud/libsacloud@v2.25.2-0.20210930043551-b491c1c2c6bd
github.com/sacloud/libsacloud v2.25.2-0.20210930043551-b491c1c2c6bd+incompatible

$ go clean -modcache

$ go1.17 list -m github.com/sacloud/libsacloud@v2.25.2-0.20210930043551-b491c1c2c6bd
go list -m: github.com/sacloud/libsacloud@v2.25.2-0.20210930043551-b491c1c2c6bd: invalid version: should be v0 or v1, not v2

(Found by @heschi during Go 1.18 pre-release testing.)

CC @matloob

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions