I have a Go project that requires some dependencies from a private GitLab repository like git.mydomain.com/myteam/category/subcategory/project.git. But I\'m getting this err
This issue is discussed at length on the GitLab support tracker.
TL;DR; It's (intentionally) broken for private repos:
Is [your group] private? If so, this is expected behavior, and I would recommend reading the discussion from #1337 (comment 36293613) onwards. In this case, we have decided to maximize security/privacy at the slight expense of usability. The recommended workaround is to specifically add .git to your URL.
The only solution I've found is to use go get's support for .netrc, which solves this both for dep
, as well as modern Go modules.
Create a Personal Access token on GitLab with api scope:
Create a ~/.netrc
file:
machine gitlab.com
login <your gitlab username>
password <the token created in step 1>
Protect your .netrc
file a bit:
chmod 600 ~/.netrc
Profit
This should now work:
dep ensure -add gitlab.com/<company>/<subgroup>/<project>
If you're using a private GitLab installation, I trust you to replace gitlab.com
with the appropriate hostname where applicable.
I think the best solution would be to use a proxy-server like athens. You could add your Gitlab-Credentials and use it as proxy-server. Athens then would handle authentication.