Golang go 使用 git ls-remote -q 使用错误的 url @ Go 1.13 失败
来源:stackoverflow
时间:2024-05-01 15:54:35 215浏览 收藏
golang学习网今天将给大家带来《Golang go 使用 git ls-remote -q 使用错误的 url @ Go 1.13 失败》,感兴趣的朋友请继续看下去吧!以下内容将会涉及到等等知识点,如果你是正在学习Golang或者已经是大佬级别了,都非常欢迎也希望大家都能给我建议评论哈~希望能帮助到大家!
好的,根据https://github.com/golang/go/issues/34094,go 1.13.3修复了这个问题
环境:go 1.13,windows
我在 windows 计算机上获得了一份新的 go 副本,并尝试在这里构建我的项目。
但是,曾经有效的 mod 现在失败了:
C:\xxx> go get -v private.repo.com/dir/utils.git get "private.repo.com/dirxxxx": found meta tag get.metaImport{Prefix:"private.repo.com/dirxxxx", VCS:"git", RepoRoot:"https://private.repo.com/dirxxxx.git"} at //private.repo.com/dirxxxx?go-get=1 get "private.repo.com": found meta tag get.metaImport{Prefix:"private.repo.com", VCS:"git", RepoRoot:"https://private.repo.com.git"} at //private.repo.com/?go-get=1 go: finding private.repo.com/dirxxxx/utils.git v0.0.5 go: downloading private.repo.com/dirxxxx/utils.git v0.0.5 go: extracting private.repo.com/dirxxxx/utils.git v0.0.5 go get private.repo.com/dirxxxx/utils.git: git ls-remote -q https://private.repo.com/dirxxxx.git in C:\Users\admin\go\pkg\mod\cache\vcs\227f0870299637a3fadb469f608679095de39005c860e3949d82a547e8c30143: exit status 128: GitLab: The project you were looking for could not be found. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
这并没有错,因为确实没有 https://private.repo.com/dirxxxx.git。
我们拥有的是 https://private.repo.com/dirxxxx/utils.git。我怎样才能强制 go git 使用某个标签或跳过 ls-remote 因为它已经找到了一个版本并提取文件哈哈
我根据 https://golang.org/doc/go1.13 配置 goproxy=direct ,因为我使用的是私人存储库。
还按照指南设置代理和其他内容,但问题仍然存在。
有什么建议吗?提前致谢!
解决方案
别名
如果您已将存储库从 https://private.repo.com/dirxxxx.git
移动到 https://private.repo.com/dirxxxx/utils.git
,则可以在 go.mod
中使用 replace directive文件定义别名路径:
replace private.repo.com/dirxxxx => private.repo.com/dirxxxx/utils v0.0.5
这样,当您运行 go get private.repo.com/dirxxxx
时,它将改为从 https://private.repo.com/dirxxxx/utils.git
获取。
https 身份验证
如果您的存储库受密码保护,您可以使用用户名和密码配置您的 git
,如下所示:
git config --global url."https://username:[email protected]/".insteadof "https://private.repo.com/"
这会在您的 ~/.gitconfig
中生成一个部分,如下所示:
[url "https://username:[email protected]/"] insteadOf = https://private.repo.com/
理论要掌握,实操不能落!以上关于《Golang go 使用 git ls-remote -q 使用错误的 url @ Go 1.13 失败》的详细介绍,大家都掌握了吧!如果想要继续提升自己的能力,那么就来关注golang学习网公众号吧!
-
502 收藏
-
502 收藏
-
501 收藏
-
501 收藏
-
501 收藏
-
139 收藏
-
204 收藏
-
325 收藏
-
477 收藏
-
486 收藏
-
439 收藏
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 立即学习 542次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 立即学习 507次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 立即学习 497次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 立即学习 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 立即学习 484次学习