Table of Contents
I just now came across the problem that I created a repository on a private GitLab instance for a Golang project and could not just use
go get ... to get it.
After a short Google search, I came across this StackOverflow question and thankfully it had a working answer.
The original StackOverflow question can be found here: StackOverflow - how do you use golang with a private gitlab repo?, the question was asked by User James Fremen. > Note: I will quote the question and answer which worked here so it is sort of archived here.
The original question
GitLab is a free, open-source way to host private .git repositories but it does not seem to work with golang. When you create a project it generates a URL of the form:where: 22.214.171.124 is the IP address of the gitlab server private-developers is a user group which has access to the private repo
Golang 1.2.1 doesn’t seem to understand this syntax.results in:
go get [email protected]:private-developers/project.git
Author of the question James Fremen
The answer that worked for me
Run this command:Assuming you have the correct privileges to
git config --global url."[email protected]:".insteadOf "https://126.96.36.199/"
git clonethe repository, this will make go get work for all repos on server
I tested this to work with go version 1.6.2 and 1.8.
Author of the answer Rick Smith
Example for DNS names
So for example with dns names, it would be for a gitlab running at
With that change, you can now successfully run
go get gitlab.example.com/example-user/example-project.