Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Go with a private GitLab repo

GitLab is a free, open-source way to host private .git repositories but it does not seem to work with Go. When you create a project it generates a URL of the form:

[email protected]:private-developers/project.git 

where:

  • 1.2.3.4 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.

go get [email protected]:private-developers/project.git 

results in:

package [email protected]/project.git: unrecognized import path "[email protected]/project.git" 

Is there a way to get this to work?

like image 582
James Fremen Avatar asked Apr 17 '15 19:04

James Fremen


People also ask

Is GitLab written in Go?

GitLab is built on top of Ruby on Rails, but we're also using Go for projects where it makes sense. Go is a very powerful language, with many advantages, and is best suited for projects with a lot of IO (disk/network access), HTTP requests, parallel processing, and so on.

Is GitLab private free?

For self-hosted private repositories, GitLab is the better choice. You can get started without having to pay any monthly subscription fee. Both options are great for open source projects, with GitLab offering premium features for free and GitHub offering access to a larger pool of active open source developers.


1 Answers

Run this command:

git config --global url."[email protected]:".insteadOf "https://1.2.3.4/" 

Assuming you have the correct privileges to git clone the repository, this will make go get work for all repos on server 1.2.3.4.

I tested this with go version 1.6.2, 1.8, and 1.9.1.

like image 87
Rick Smith Avatar answered Oct 13 '22 02:10

Rick Smith