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

How to override VCS location for quirky dependencies in go.mod? #35509

Closed
mcandre opened this issue Nov 11, 2019 · 3 comments
Closed

How to override VCS location for quirky dependencies in go.mod? #35509

mcandre opened this issue Nov 11, 2019 · 3 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@mcandre
Copy link

mcandre commented Nov 11, 2019

Many Go libraries use a different VCS URL than the Go import path would imply, such as the /x/ libraries, the common YAML library, and any secondary forks of regular Go libraries.

For these kinds of dependencies, what is the right syntax in go.mod for overriding the VCS URL of the dependency?

@mvdan
Copy link
Member

mvdan commented Nov 11, 2019

Have you tried go mod edit -replace=old/module=github.com/you/fork?

@mvdan mvdan added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Nov 11, 2019
@thepudds
Copy link
Contributor

thepudds commented Nov 16, 2019

Many Go libraries use a different VCS URL than the Go import path would imply, such as the /x/ libraries

@mcandre This might not be helpful to answer your full question, but taking the /x/ libraries example: in the go.mod of a consumer of the /x/ libraries, the consumer uses the identity declared in the module line of go.mod file for the /x/ library of interest. For example, the golang.org/x/tools go.mod declares itself to be module golang.org/x/tools:

https://github.com/golang/tools/blob/master/go.mod#L1

So you would refer to it as golang.org/x/tools in a consumer’s go.mod file.

In general, a module declares its identity in its go.mod via the module directive (e.g., a first line reading module example.com/m ). The go tool enforces consistency between that declared module path and the import paths used by any consumer.

This is part of how the go tool (in module mode) enforces that "import path == identity of the code" for any given package.

If a module's go.mod file reads module example.com/m, then a consumer must import packages from that module using import paths that start with that module path (e.g., import "example.com/m" or import "example.com/m/sub/pkg").

Were you hitting a specific problem?

If so, what was the specific command issued, and specific error message, if any?

@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants