Abel'Blog

我干了什么?究竟拿了时间换了什么?

0%

go[7]-mod用法

简介

今天在使用库发现里面的grpc库已经被废弃了。记录一下如何处理的。

细则

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 下面有报错:
go mod tidy
go: finding module for package github.com/okex/exchain-go-sdk
go: found github.com/okex/exchain-go-sdk in github.com/okex/exchain-go-sdk v1.5.6
go: finding module for package github.com/gogo/protobuf/grpc
go: market_data_service/src/okxapi imports
github.com/okex/exchain-go-sdk imports
github.com/okex/exchain/libs/ibc-go/modules/apps/transfer/types imports
github.com/gogo/protobuf/grpc: module github.com/gogo/protobuf@latest found (v1.3.2), but does not contain package github.com/gogo/protobuf/grpc
# 返回去找到他们的库
github.com/okex/exchain
# go.mod 里面使用了 replace 将某个

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
# 其实这个问题就是说 protobuf 最新版本已经将 grpc 废弃掉了,但是他们的一个tx.proto.go文件还在使用这个。
libs/ibc-go/modules/apps/transfer/types/tx.pb.go
import (
grpc1 "github.com/gogo/protobuf/grpc"
)
这个文件估计是比较古早的代码,需要使用特殊版本。

解决版本模糊报错

ambiguous [amˈbiɡyəwəs] 模糊的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
o mod tidy
go: finding module for package github.com/gocolly/colly/v2
go: found github.com/gocolly/colly/v2 in github.com/gocolly/colly/v2 v2.1.0
go: spider-qihang-lottery/cmd/bsc_contract_query/contract imports
github.com/ethereum/go-ethereum/accounts/abi imports
github.com/ethereum/go-ethereum/crypto imports
github.com/btcsuite/btcd/btcec/v2/ecdsa tested by
github.com/btcsuite/btcd/btcec/v2/ecdsa.test imports
github.com/btcsuite/btcd/chaincfg/chainhash: ambiguous import: found package github.com/btcsuite/btcd/chaincfg/chainhash in multiple modules:
github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6 (/Users/abel/go/pkg/mod/github.com/btcsuite/btcd@v0.0.0-20171128150713-2e60448ffcc6/chaincfg/chainhash)
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 (/Users/abel/go/pkg/mod/github.com/btcsuite/btcd/chaincfg/chainhash@v1.0.1)

go get github.com/btcsuite/btcd/chaincfg/chainhash@latest
go: upgraded github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 => v1.1.0

go mod tidy
go: finding module for package github.com/gocolly/colly/v2
go: found github.com/gocolly/colly/v2 in github.com/gocolly/colly/v2 v2.1.0