我们有一个只能通过 ssh/git (无 https)访问的私有代码存储库,并且我们希望在那里托管我们的 go 代码/模块。
首先我尝试:
git config --global url."git@code.internal.local:".insteadOf "https://code.internal.local/"
Run Code Online (Sandbox Code Playgroud)
因此,以下两项都可以正常工作:
git clone git@code.internal.local:reponame.gitgit clone https://code.internal.local/reponame但go get code.internal.local/reponame失败了,因为 go 仍然坚持尝试 https://...而不是 git。
package code.internal.local/reponame: unrecognized import path "code.internal.local/reponame": https fetch: Get "https://code.internal.local/reponame?go-get=1": dial tcp 192.168.0.5:443: i/o timeout
Run Code Online (Sandbox Code Playgroud)