我正在寻找获得$ go与私人存储库工作的方法,经过许多谷歌尝试。
第一次尝试:
$ 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
是的,它没有看到元标签,因为我不知道如何提供登录信息。
第二次尝试:
按照https://gist.github.com/shurcooL/6927554。将config添加到.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
是的,它的工作,但与。git扩展与我的项目名称,我可以重命名为原来的,但每次做$ go get不太好,有没有其他方法?
我已经创建了一个特定于用户的ssh-config,因此我的用户可以使用正确的凭证和密钥自动登录。
首先,我需要生成一个密钥对
ssh-keygen -t rsa -b 4096 -C "my@email.here"
并保存到例如~/.ssh/id_my_domain。请注意,这也是我连接到我的Github帐户的对口令(私有和公共),所以我的存储在~/.ssh/id_github_com。
然后我创建(或修改)了一个名为~/的文件。Ssh /config有一个条目:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_github_com
在另一个服务器上,“ssh-url”是admin@domain.com:username/private-repo.git,这个服务器的条目应该是:
Host domain.com
HostName domain.com
User admin
IdentityFile ~/.ssh/id_domain_com
澄清一下,您需要确保正确设置了User、Host和HostName。
现在我可以浏览到go路径,然后去get <package>,例如去get main文件main/main。Go包含包(来自上一个例子)domain.com:username/private-repo.git。
我已经创建了一个特定于用户的ssh-config,因此我的用户可以使用正确的凭证和密钥自动登录。
首先,我需要生成一个密钥对
ssh-keygen -t rsa -b 4096 -C "my@email.here"
并保存到例如~/.ssh/id_my_domain。请注意,这也是我连接到我的Github帐户的对口令(私有和公共),所以我的存储在~/.ssh/id_github_com。
然后我创建(或修改)了一个名为~/的文件。Ssh /config有一个条目:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_github_com
在另一个服务器上,“ssh-url”是admin@domain.com:username/private-repo.git,这个服务器的条目应该是:
Host domain.com
HostName domain.com
User admin
IdentityFile ~/.ssh/id_domain_com
澄清一下,您需要确保正确设置了User、Host和HostName。
现在我可以浏览到go路径,然后去get <package>,例如去get main文件main/main。Go包含包(来自上一个例子)domain.com:username/private-repo.git。