经过谷歌的多次尝试,我正在寻找让$ go get
与私有存储库一起工作的方法。
第一次尝试:
$ 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
是的,它看不到meta标签,因为我不知道如何提供登录信息。
第二次尝试:
沿着https://gist.github.com/shurcooL/6927554行驶。将配置添加到.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
扩展名,我可以将它重命名为original,但每次$ go get
不是那么好的时候都这样做,有没有其他方法?
发布于 2014-12-16 17:12:07
您有一件事需要配置。这个例子是基于GitHub的,但是这不应该改变这个过程:
$ git config --global url.git@github.com:.insteadOf https://github.com/
$ cat ~/.gitconfig
[url "git@github.com:"]
insteadOf = https://github.com/
$ go get github.com/private/repo
要让Go模块工作(使用Go 1.11或更高版本),您还需要设置GOPRIVATE
变量,以避免使用公共服务器获取代码:
export GOPRIVATE=github.com/private/repo
发布于 2014-12-16 17:20:12
正确的方法是手动将存储库放在正确的位置。一旦存储库存在,您就可以使用go get -u
更新软件包,使用go install
安装它。一个名为的包
github.com/secmask/awserver-go
进入
$GOPATH/src/github.com/secmask/awserver-go
您键入的命令包括:
cd $GOPATH/src/github.com/secmask
git clone git@github.com:secmask/awserver-go.git
发布于 2017-08-29 18:25:38
我在我们公司的gitlab上使用私有存储库时遇到了go get
的问题。我在寻找解决方案的过程中浪费了几分钟。我找到了这个:
https://gitlab.mycompany.com/profile/account
$ git config --global ssh“YOUR_PRIVATE_TOKEN
$ git "https://gitlab.mycompany.com/"
go get
您可以正常使用url:$ go获取gitlab.com/company/private_repo
https://stackoverflow.com/questions/27500861
复制相似问题