go get或go mod tidy报错 fatal: could not read Username for

8 篇文章 0 订阅

go get git.xxxxx.net/CPC/protocol: module git.xxxxx.net/CPC/protocol: git ls-remote -q origin in /Users/admin/go/pkg/mod/cache/vcs/b23efdb68de4fde955075014c720200fc58c6052bbf3cd57ed65bf341c19c359: exit status 128:
fatal: could not read Username for ‘https://git.xxxxx.net’: terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see https://golang.org/doc/faq#git_https for additional information

go get 下载依赖出错,但是项目是可以正常clone下来的,从上面报错信息可以看出是因为找不到git远程仓库的用户名信息,解决办法修改 ~/.gitconfig 让go使用ssh协议拉取代码
在 ~/.gitconfig 中添加以下信息

[url "ssh://git@git.xxxxxxxxxxxx.net/"]
	insteadOf = https://git.xxxxxxxxxxxx.net/

把git.xxxxxxxxxxxx.net 替换为你真实的git仓库地址

具体请参考 https://golang.org/doc/faq#git_https

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值