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

proposal: cmd/go: the target of replace directive in go.mod support a remote location #58736

bigwhite opened this issue Feb 26, 2023 · 1 comment


Copy link

bigwhite commented Feb 26, 2023

I propose to extend the syntax of go.mod's replace directive to support a remote location target. the remote location that is always the repo hosted in a remote self-hosted git server(or other vcs server) can be a valid target of replace. the below go.mod is an example of my proposal. we know the example is invalid in latest go version.

go 1.20

require ( v1.1.0

replace v1.1.0 => v1.1.0

or replace  =>

or replace  => v1.1.0

or replace  v1.1.0 =>


Even though Go has evolved to Go 1.20, smaller go development teams still have problems with complex configurations for pulling private modules.

Take our team for example, the private modules that our project depends on are placed on a self-built gitlab server (e.g., which is not accessible via domain name, but only via ip address, and we have defined the canonical import path ( for these private modules.

Our solution now is to pull these private modules through a private self-built GO proxy server (e.g., And each developer needs to configure like below:

export GOPROXY='|'

Although not particularly complex, maintaining the private GO PROXY service is tedious for small team like us. We want to be able to pull these private modules with cannoical import paths without using a private proxy.

Inspired by rust cargo, we thought about whether our requirement could be achieved based on the current go module mechanism:

- Based on the existing syntax
- Minimal changes
- go.mod can be submitted to the codebase for versioning, and all group members can use it without using

I came up with the idea of doing it based on go mod replace, which of course requires some extensions to replace.

Once the new proposal is implemented, the subsequent pulling of private modules hosted on our self-built gitlab server by our team will allow us to configure none.

And most importantly, there is no need to maintain a private GO proxy service. and It is extremely easy for small team like us to pull private module(with canonical import path ) hosted in a remote self-hosted vcs server.

It is likely that many small development teams will encounter similar problems to ours.

Related issues but not the same

@gopherbot gopherbot added this to the Proposal milestone Feb 26, 2023
Copy link

This already works, use the import path that you would have used if it wasn't in a replace directive


@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2023
@golang golang locked and limited conversation to collaborators Feb 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

No branches or pull requests

3 participants