Golang中`go get`获取私有模块时遇到的问题
Golang中go get获取私有模块时遇到的问题
在导入私有模块时遇到问题,列出了调试和详细日志,但无法找出原因…:
$ go get -x -v private-gitlab.com/orgname/subgroup/myproject-go
# get https://private-gitlab.com/orgname/subgroup/myproject-go?go-get=1
# get https://private-gitlab.com/orgname/subgroup/myproject-go?go-get=1: 200 OK (0.095s)
get "private-gitlab.com/orgname/subgroup/myproject-go": found meta tag vcs.metaImport{Prefix:"private-gitlab.com/orgname/subgroup", VCS:"git", RepoRoot:"https://private-gitlab.com/orgname/subgroup.git"} at //private-gitlab.com/orgname/subgroup/myproject-go?go-get=1
get "private-gitlab.com/orgname/subgroup/myproject-go": verifying non-authoritative meta tag
# get https://private-gitlab.com/orgname/subgroup?go-get=1
# get https://private-gitlab.com/orgname/subgroup?go-get=1: 200 OK (0.038s)
mkdir -p /home/username/go/pkg/mod/cache/vcs # git3 https://private-gitlab.com/orgname/subgroup.git
# lock /home/username/go/pkg/mod/cache/vcs/5992a5e5b7a53bbdd91113a9673fe0b4d486cf6d2db09a1dc466f05595aeb817.lock
# /home/username/go/pkg/mod/cache/vcs/5992a5e5b7a53bbdd91113a9673fe0b4d486cf6d2db09a1dc466f05595aeb817 for git3 https://private-gitlab.com/orgname/subgroup.git
cd /home/username/go/pkg/mod/cache/vcs/5992a5e5b7a53bbdd91113a9673fe0b4d486cf6d2db09a1dc466f05595aeb817; git ls-remote -q origin
1.919s # cd /home/username/go/pkg/mod/cache/vcs/5992a5e5b7a53bbdd91113a9673fe0b4d486cf6d2db09a1dc466f05595aeb817; git ls-remote -q origin
# get https://private-gitlab.com/orgname/subgroup.git
# get https://private-gitlab.com/orgname/subgroup.git: 200 OK (0.094s)
go: module private-gitlab.com/orgname/subgroup/myproject-go: git ls-remote -q origin in /home/username/go/pkg/mod/cache/vcs/5992a5e5b7a53bbdd91113a9673fe0b4d486cf6d2db09a1dc466f05595aeb817: exit status 128:
remote:
remote: ========================================================================
remote:
remote: The project you were looking for could not be found or you don't have permission to view it.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
以下两种方式都能正常工作:
git clone git@private-gitlab.com:orgname/subgroup/myproject-go.git
git clone https://private-gitlab.com/orgname/subgroup/myproject-go.git
我已经在全局的 .gitconfig 中启用了以下配置:
[url "git@private-gitlab.com:"]
insteadOf = https://private-gitlab.com/
我没有设置 .netrc,因为我更希望它能通过 SSH 工作…
更多关于Golang中`go get`获取私有模块时遇到的问题的实战教程也可以访问 https://www.itying.com/category-94-b0.html
2 回复


