Description
Proposal: Allow GOPRIVATE to provide source repository URI
Last updated: 2021/04/24
Rationale:
In current state of Go modules' tooling, working with private repositories without setting up a private proxy infrastructure serving modules over https is possible but cumbersome; and still is confined to git VCS only.
For git repositories it is usually done like that:
go env -w GOPRIVATE=example.com
git config --global url."[email protected]:".insteadOf "https://example.com"
This configuration works, but it has to be global (per machine/user). To my knowledge no other VCS allows for such workaround.
Related:
#40189 : add a sub command to manage authentication
Proposal:
Allow GOPRIVATE to point to the source repository for a given module path matching pattern. Let user provide vcs type, transport, and credentials.
GOPRIVATE=pattern["["vcs+transport://[userid[:password]@]host[:port][/path]"]"][,...]
GOPRIVATE=example.com/[fossil+ssh://internal.example.com]
GOPRIVATE=example.com/[git+ssh://[email protected]]
GOPRIVATE=example.com/[fossil+https://internal.example.com]
GOPRIVATE=example.com/[git+https://testing.example.com/test]
If pattern ends with slash, allow URI to be constructed using parts of matched module path represented by five percent-letter variables:
matched.pattern/path/to/module
^^^^^^ %z end element of module path
^^^^ %s start element after the match
^^^^^^^^^^^^^^ %p part after the match
^^^^^^^^^^^^^^^ %m matched by (excluding ending slash)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %w whole module path
example.com[git+file:///repos/%p.git] # get from bare repos archive
example.com[fossil+file:///repos/%s-%z.fossil] # or a bag of user fossils
github.com/myuser/[git+file:///gopath/src/%w/] # use old GOPATH as source
example.com/[git+ssh://%[email protected]:2222/%p.git] # per CI domain
Reserved characters of RFC 3986 that should be literal part of produced URI must be given in percent-encoding form. Literal characters ":", "[", "]", "", and "@" can also be provided after a backslash character.
edits:
- 2021/04/24 add reference to #40189; add "reserved characters encoding" note.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status