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

x/mod/modfile: Parse only sets Module.Mod.Path, not Version #50242

Closed
LittleFox94 opened this issue Dec 17, 2021 · 1 comment
Closed

x/mod/modfile: Parse only sets Module.Mod.Path, not Version #50242

LittleFox94 opened this issue Dec 17, 2021 · 1 comment

Comments

@LittleFox94
Copy link

LittleFox94 commented Dec 17, 2021

When using golang.org/x/mod/modfile.Parse() to parse a go.mod file into file File, I expect file.Module.Mod to have both Path and Version set. Instead, only Path is set - including the version as last element.

The go.mod contained this line: module github.com/onsi/ginkgo/v2 (the exact package being not important), running in dlv I confirmed the behavior:

(dlv) p file.Module.Mod
golang.org/x/mod/module.Version {
	Path: "github.com/onsi/ginkgo/v2",
	Version: "",}

I used file, err := modfile.Parse(fmt.Sprintf("go.mod@%v", version), fileContents, nil) to parse the file, no error was returned. The filename given as argument should be irrelevant to this problem.

Please either change the code to have Path and Version set or document this is not the case and what users should do instead.

Version details
go version go1.17.5 linux/amd64
golang.org/x/mod version v0.5.1
@gopherbot gopherbot added this to the Unreleased milestone Dec 17, 2021
@seankhliao
Copy link
Member

the Version.Version field documents the expected contents, in this case:

First, the top-level target of a build has no specific version and uses Version = ""

@golang golang locked and limited conversation to collaborators Dec 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants