【发布时间】:2021-05-01 10:49:39
【问题描述】:
我正在使用 Go 模块。
为了使用模块版本,我不能使用本地模块。例如:
replace locakpkg => ../localpkg v0.1.0
上述操作将失败,因为替换本地路径到目前为止还没有版本(转到 1.15)。
因此,为了使模块版本正常工作,我决定使用私有 ssh 存储库。
我确实搜索了如何使私人 ssh 存储库工作两天。
通过关注许多在线文章,我做到了
git config --global url.user@private.com:.insteadOf https://private.com/
go env -w GOPRIVATE=private.com
我发现 go get 总是会做 https fetch 来检查 ssl 凭证。所以我也正确配置了一个 https 服务器。
但最后,我还是得到了一个错误信息:
unrecognized import path "private.com/foo": reading https://private.com/foo?go-get=1: 404 Not Found
我用谷歌搜索了这个错误,发现了这个规范 https://golang.org/ref/mod#vcs-find,它说我必须让服务器回复 <meta name="go-import" content="root-path vcs repo-url"> 以获取 https 获取请求。
-
如果有办法在本地模块包中使用 git tag 版本控制,我可以在 go.mod 中使用本地替换,而不是配置私有 ssh repo。
-
如果以上几点都不可能,我配置私有ssh repo时如何避免https fetch?我认为 ssh repo 与 https 协议无关。
【问题讨论】:
标签: go go-modules