go mod处理第三方依赖包时出现unknown revision xxx错误。
原因:github上面的一些开源组件,用的git版本是最新的版本。 而编辑机的git版本比较旧,有的git命令没有,导致下载失败。
解决方法:升级git到最新版本(目前是2.35.1)。
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
还有原因可能是因为golang包是私有包的问题,配置gomod支持私有包下载:
linux配置
export GOPRIVATE=gitlab.xxx.com/xxxx/*
私有仓库问题: 如果是自己搭建的git 服务器。
golang 设置(私有仓库)环境变量:
go env -w GOPRIVATE="gitlab.xxx.com/xxxx/*"
linux设置环境变量:
export GOPRIVATE=gitlab.xxx.com/xxxx/*
windows设置环境变量:
$env:GOPRIVATE="gitlab.XXXX.com/XXX/*"
或:
git config --global url."git@gitlab.xxxx.com:".insteadOf http://gitlab.xxxx.com/
通过git配置文件设置:
[url "git@gitlab.xxxx.com:"]
insteadOf = http://gitlab.xxxxx.com/
记住密码:
git config --global credential.helper store
下载依赖:
go mod tidy
或
go mod download
查看需要替换的依赖包:
root@jack-VirtualBox:~/lotus/lotus
./go.mod:54: github.com/filecoin-project/specs-storage v0.1.1-0.20211228030229-6d460d25a0c9
./go.sum:385:github.com/filecoin-project/specs-storage v0.1.1-0.20211228030229-6d460d25a0c9 h1:oUYOvF7EvdXS0Zmk9mNkaB6Bu0l+WXBYPzVodKMiLug=
./go.sum:386:github.com/filecoin-project/specs-storage v0.1.1-0.20211228030229-6d460d25a0c9/go.mod h1:Tb88Zq+IBJbvAn3mS89GYj3jdRThBTE/771HCVZdRJU=
./testplans/lotus-soup/go.sum:474:github.com/filecoin-project/specs-storage v0.1.1-0.20211228030229-6d460d25a0c9 h1:oUYOvF7EvdXS0Zmk9mNkaB6Bu0l+WXBYPzVodKMiLug=
./testplans/lotus-soup/go.sum:475:github.com/filecoin-project/specs-storage v0.1.1-0.20211228030229-6d460d25a0c9/go.mod h1:Tb88Zq+IBJbvAn3mS89GYj3jdRThBTE/771HCVZdRJU=
root@jack-VirtualBox:~/lotus/lotus
查看本地现有的包版本:
root@jack-VirtualBox:~/lotus/lotus
/root/go-path/pkg/mod/github.com/filecoin-project/specs-storage@v0.1.1-0.20200907031224-ed2e5cd13796:
CONTRIBUTING.md COPYRIGHT go.mod go.sum LICENSE-APACHE LICENSE-MIT Makefile README.md storage
/root/go-path/pkg/mod/github.com/filecoin-project/specs-storage@v0.1.1-0.20201105051918-5188d9774506:
CONTRIBUTING.md COPYRIGHT go.mod go.sum LICENSE-APACHE LICENSE-MIT Makefile README.md storage
/root/go-path/pkg/mod/github.com/filecoin-project/specs-storage@v0.1.1-0.20211228030229-6d460d25a0c9:
CONTRIBUTING.md COPYRIGHT go.mod go.sum LICENSE-APACHE LICENSE-MIT Makefile README.md storage
root@jack-VirtualBox:~/lotus/lotus
替换依赖包的版本:
root@jack-VirtualBox:~/lotus/lotus
root@jack-VirtualBox:~/lotus/lotus
|