I'm searching for the way to get $ go get
work with private repository, after many google try.
The first try:
$ go get -v gitlab.com/secmask/awserver-go
Fetching https://gitlab.com/secmask/awserver-go?go-get=1
https fetch failed.
Fetching http://gitlab.com/secmask/awserver-go?go-get=1
Parsing meta tags from http://gitlab.com/secmask/awserver-go?go-get=1 (status code 200)
import "gitlab.com/secmask/awserver-go": parse http://gitlab.com/secmask/awserver-go?go-get=1: no go-import meta tags
package gitlab.com/secmask/awserver-go: unrecognized import path "gitlab.com/secmask/awserver-go
Yep, it did not see the meta tags because I could not know how to provide login information.
The second try:
Follow https://gist.github.com/shurcooL/6927554. Add config to .gitconfig.
[url "ssh://git@gitlab.com/"]
insteadOf = https://gitlab.com/
$ go get -v gitlab.com/secmask/awserver-go --> not work
$ go get -v gitlab.com/secmask/awserver-go.git --> work but I got src/gitlab.com/secmask/awserer-go.git
Yes it work but with .git
extension with my project name, I can rename it to original but do it everytime $ go get
is not so good, is there an otherway?
If you've already got git using SSH, this answer by Ammar Bandukwala is a simple workaround:
$ go get
usesgit
internally. The following one liners will makegit
and consequently$ go get
clone your package via SSH.Github:
BitBucket:
According to this link - https://gist.github.com/shurcooL/6927554 - you have two things to configure. The example is based on GitHub but this shouldn't change the process
The proper way is to manually put the repository in the right place. Once the repository is there, you can use
go get -u
to update the package andgo install
to install it. A package namedgoes into
The commands you type are:
Generate a github oauth token here and export your github token as an environment variable:
Set git config to use the basic auth url:
Now you can
go get
your private repo.I had a problem with
go get
using private repository on gitlab from our company. I lost a few minutes trying to find a solution. And I did find this one:You need to get a private token at:
https://gitlab.mycompany.com/profile/account
Configure you git to add extra header with your private token:
Configure your git to convert requests from ssh to http:
Finally you can use your
go get
normally:That looks like the GitLab issue 5769.
It is supposed to be resolved in “Added support for Go's repository retrieval. #5958”, provided the right meta tags are in place.
Although there is still an issue for Go itself: “
cmd/go
: go get cannot discover meta tag in HTML5 documents”.