Go: go mod获取第三方依赖包unknown revision xxx错误解决

Go: go mod获取第三方依赖包unknown revision xxx错误解决

使用go mod处理第三方依赖包时出现unknown revision xxx错误,解决方法如下:

以go-chassis为例:

[test1280@localhost ~]$ git clone https://github.com/go-chassis/go-chassis.git
Initialized empty Git repository in /home/test1280/go-chassis/.git/
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
Receiving objects: 100% (6979/6979), 2.55 MiB | 17 KiB/s, done.
remote: Total 6979 (delta 0), reused 0 (delta 0), pack-reused 6976
Resolving deltas: 100% (4159/4159), done.
[test1280@localhost ~]$ cd go-chassis/
[test1280@localhost go-chassis]$ go mod download
go: finding github.com/patrickmn/go-cache v2.1.0+incompatible
go: finding github.com/openzipkin-contrib/zipkin-go-opentracing v0.0.0-20180726151020-b85dc675b16b
go: finding github.com/cenkalti/backoff v2.0.0+incompatible
go: finding github.com/go-chassis/go-restful-swagger20 v0.0.0-20181221101811-a33c76fe4a6e
go: finding github.com/hashicorp/go-version v1.0.0
go: finding github.com/gorilla/websocket v1.4.0
go: finding github.com/go-chassis/go-archaius v0.7.0
go: finding github.com/smartystreets/goconvey v0.0.0-20170602164621-9e8dc3f972df
go: github.com/cenkalti/[email protected]+incompatible: unknown revision v2.0.0
go: github.com/patrickmn/[email protected]+incompatible: unknown revision v2.1.0
go: github.com/hashicorp/[email protected]: unknown revision v1.0.0
go: github.com/gorilla/[email protected]: unknown revision v1.4.0
go: github.com/go-chassis/[email protected]: unknown revision v0.7.0
……

有的第三方依赖包可以从github找到,但是有的找不到,报错:unknown revision xxx。

其实go mod调用链中会用到一些git指令,当git版本比较旧时,调用失败产生错误,并给出歧义的提示信息。

升级git版本,可参考这篇博客。

升级完毕后,再尝试go mod:

[test1280@localhost go-chassis]$ git --version
git version 2.20.1
[test1280@localhost go-chassis]$ go mod download
go: finding github.com/gorilla/websocket v1.4.0
go: finding github.com/hashicorp/go-version v1.0.0
go: finding github.com/go-chassis/go-restful-swagger20 v0.0.0-20181221101811-a33c76fe4a6e
go: finding github.com/cenkalti/backoff v2.0.0+incompatible
go: finding github.com/openzipkin-contrib/zipkin-go-opentracing v0.0.0-20180726151020-b85dc675b16b
go: finding github.com/patrickmn/go-cache v2.1.0+incompatible
go: finding github.com/smartystreets/goconvey v0.0.0-20170602164621-9e8dc3f972df
go: finding github.com/go-chassis/go-archaius v0.7.0
go: finding github.com/prometheus/common v0.2.0
go: finding github.com/go-chassis/paas-lager v0.0.0-20181123014243-005283cca84c
go: finding github.com/json-iterator/go v1.1.5
go: finding gopkg.in/yaml.v2 v2.2.1
go: finding github.com/pierrec/lz4 v2.0.5+incompatible
go: finding github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1
go: finding github.com/golang/protobuf v1.2.0
go: finding github.com/go-mesh/openlogging v0.0.0-20181122085847-3daf3ad8ed35
go: finding github.com/go-logfmt/logfmt v0.4.0
go: finding github.com/go-chassis/go-cc-client v0.5.0
go: finding github.com/spf13/cast v1.2.0
go: finding github.com/go-chassis/foundation v0.0.0-20190203091418-304855ea28bf
go: finding github.com/rcrowley/go-metrics v0.0.0-20180503174638-e2704e165165
go: finding github.com/modern-go/reflect2 v1.0.1
go: finding github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515
go: finding github.com/pkg/errors v0.8.0
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/prometheus/client_golang v0.9.1
go: finding github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d
go: finding github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc
go: finding github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f
go: finding go.uber.org/ratelimit v0.0.0-20180316092928-c15da0234277
go: finding github.com/julienschmidt/httprouter v1.2.0
……

已经可以从github上找到指定版本的第三方依赖包啦!

参考:

1.https://pureage.info/post/bad-feeling-about-go-cmd/

你可能感兴趣的:(GO,那些年我踩过的坑,unknown,revision,go,mod,go-chassis,go,module,go)