fatal: ‘origin‘ does not appear to be a git repository

本文介绍如何处理Go编译过程中遇到的invalidversion错误,重点在于git拉取依赖库失败,通过删除GOPATH下特定缓存文件夹来修复。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. Go编译报错信息

E:\work\hqsource\stock\quote_sh_l2_parser>go build
go: xxxxxxx/yyyyyyyy/quote_lib@v0.3.115-0.20220302053425-232076327f09: invalid version: git ls-remote -q origin in C:\Go\repository\pkg\mod\cache\vcs\87198654213a7c861ce67251dbddf3f94fb383755ea8e89812eb7f12fc9c666e: exit status 128:
        fatal: 'origin' does not appear to be a git repository
        fatal: Could not read from remote repository.

        Please make sure you have the correct access rights
        and the repository exists.

go编译时,git需要拉取对应的依赖库,拉取依赖库时,会先去GOPATH路径下的缓存去查找,如果缓存不正确,就有可能导致莫名其妙的问题。上面问题关键在这里

invalid version: git ls-remote -q origin in C:\Go\repository\pkg\mod\cache\vcs\87198654213a7c861ce67251dbddf3f94fb383755ea8e89812eb7f12fc9c666e

2. 解决方案

 删除go同步依赖库的缓存,很多时候可能由于缓存有问题,造成了莫名其妙的错误,就类似于Java项目的maven时,依赖库没有正确下载,后续因为缓存库引入有问题,需要重新清理一下缓存才能正确编译和使用。

现在我们找到上面的文件夹,然后删除此文件夹。文件的路劲根据提示自己确认。我的需要删除的文件夹如下

C:\Go\repository\pkg\mod\cache\vcs\87198654213a7c861ce67251dbddf3f94fb383755ea8e89812eb7f12fc9c666e

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值