Gitlab Subgroup + go get
Given:
gitlab, most likely deployed inside an internal network;- “perfectionism” that demands everything be filed neatly into folders, or a directive from above;
- an internal
Gopackage that needs to be installed as a dependency.
Suppose your dependency lives at:
https://gitlab.your-company.tld/project-group/lib-group/lib
Unfortunately, you can’t install it just by passing the package name. There are two paths forward:
- append
.gitto the repository name; - use the
replacedirective ingo.mod.
The first option is the simplest, but I think most would agree it’s pretty unappealing.
The second option, using replace, would look like this for the example above:
module ...
go 1.XX
require (
...
gitlab.your-company.tld/project-group/lib-group/lib vTAG
...
)
replace gitlab.your-company.tld/project-group/lib-group/lib => gitlab.your-company.tld/project-group/lib-group/lib.git v<TAG>
You may also need a url rewrite in ~/.gitconfig, but it’s better to confirm that with whoever set up your
gitlab. In the overwhelming majority of cases it’ll look something like this:
[url "ssh://git@gitlab.your-company.tld:"]
insteadOf = https://gitlab.your-company.tld