god mod 本文以码云上的私有项目为例,讲述如何解决这个问题。
# 1. 设置 SSH 公钥
go mod # 2. 配置 git 将请求从 https 转换为 ssh
testmod git config --global url."git@gitee.com:rockyang/testmod.git".insteadOf "https://gitee.com/rockyang/testmod.git"
testmod go get -u -v gitee.com/rockyang/testmod
Fetching https://gitee.com/rockyang/testmod?go-get=1
Parsing meta tags from https://gitee.com/rockyang/testmod?go-get=1 (status code 200)
get "gitee.com/rockyang/testmod": found meta tag get.metaImport{Prefix:"gitee.com/rockyang/testmod", VCS:"git", RepoRoot:"https://gitee.com/rockyang/testmod.git"} at https://gitee.com/rockyang/testmod?go-get=1
go: finding gitee.com/rockyang/testmod latest
Fetching https://gitee.com/rockyang?go-get=1
Parsing meta tags from https://gitee.com/rockyang?go-get=1 (status code 200)
get "gitee.com/rockyang": found meta tag get.metaImport{Prefix:"gitee.com/rockyang", VCS:"git", RepoRoot:"https://gitee.com/rockyang"} at https://gitee.com/rockyang?go-get=1
Fetching https://gitee.com?go-get=1
Parsing meta tags from https://gitee.com?go-get=1 (status code 200)
你会发现,已经可以正常拉取了。