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?
I have created a user specific ssh-config, so my user automatically logs in with the correct credentials and key.
First I needed to generate an key-pair
and saved it to e.g
~/.ssh/id_my_domain
. Note that this is also the keypair (private and public) I've connected to my Github account, so mine is stored in~/.ssh/id_github_com
.I have then created (or altered) a file called
~/.ssh/config
with an entry:On another server, the "ssh-url" is
admin@domain.com:username/private-repo.git
and the entry for this server would have been:Just to clarify that you need ensure that the
User
,Host
andHostName
is set correctly.Now I can just browse into the go path and then
go get <package>
, e.ggo get main
where the filemain/main.go
includes the package (from last example above)domain.com:username/private-repo.git
.