golang导入私有仓库报错:“server response: not found:xxx: invalid version: git ls-remote -q origin in xxx“

9 篇文章 0 订阅
4 篇文章 0 订阅

1.问题:go get导入私有仓库报错

➜   go get "devops.gitlab.xxx.com/test/kafka-utils"
go: devops.gitlab.xxx.com/test/kafka-utils@v0.0.1: verifying go.mod: devops.gitlab.xxx.com/testo/kafka-utils@v0.0.1/go.mod: reading https://goproxy.cn/sumdb/sum.golang.org/lookup/devops.gitlab.xxx.com/test/kafka-utils@v0.0.1: 404 Not Found
        server response:
        not found: devops.gitlab.xxx.com/test/kafka-utils@v0.0.1: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/4eca6870c5eba21f85d126a33da76e0445c3741603369eb6c7037cbbb88e9a16: exit status 128:
                fatal: could not read Username for 'https://devops.gitlab.xxx.com': 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.

2.尝试过但不生效的方法

首先,已经确认在gitlab上设置过ssh自己设备的public key。

未生效的方法:(这个方法网上给出的最多,但是对我不适用)

git config --global url."ssh://git@devops.gitlab.xxx.com".insteadof "https://devops.gitlab.xxx.com"

3.生效的方法

将GOPRIVATE改为私有仓库的域名

go env -w GOPRIVATE="devops.gitlab.xxx.com"
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值