我正在寻找获得的方法$ 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
是的,它没有看到元标记,因为我不知道如何提供登录信息。
第二次尝试:
Follow https://gist.github.com/shurcooL/6927554 https://gist.github.com/shurcooL/6927554。将配置添加到 .gitconfig。
[url "ssh://[email protected] /cdn-cgi/l/email-protection/"]
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
不太好,还有其他办法吗?
您需要配置一件事。该示例基于 GitHub,但这不应改变流程:
$ git config --global [email protected] /cdn-cgi/l/email-protection:.insteadOf https://github.com/
$ cat ~/.gitconfig
[url "[email protected] /cdn-cgi/l/email-protection:"]
insteadOf = https://github.com/
$ go get github.com/private/repo
为了让 Go 模块正常工作(使用 Go 1.11 或更高版本),您还需要设置GOPRIVATE
变量,以避免使用公共服务器来获取代码:
export GOPRIVATE=github.com/private/repo
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)