我正在寻找获取$ go get
的方法经过多次谷歌尝试后,使用私有(private)存储库。
第一次尝试:
$ 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 .将配置添加到 .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
不是很好,有没有其他办法?
最佳答案
您需要配置一件事。该示例基于 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
变量,以避免使用公共(public)服务器来获取代码:export GOPRIVATE=github.com/private/repo
关于git - "go get"私有(private)存储库的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62083787/