报错信息
D:\go_env\bin\go.exe build -o C:\Users\jhinno\AppData\Local\Temp\___go_build_test_etcd_go.exe -gcflags "all=-N -l" D:/go_code/test_data/test_etcd.go #gosetup
# github.com/coreos/etcd/clientv3/balancer/resolver/endpoint
C:\Users\jhinno\go\pkg\mod\github.com\coreos\etcd@v3.3.25+incompatible\clientv3\balancer\resolver\endpoint\endpoint.go:114:78: undefined: resolver.BuildOption
C:\Users\jhinno\go\pkg\mod\github.com\coreos\etcd@v3.3.25+incompatible\clientv3\balancer\resolver\endpoint\endpoint.go:182:31: undefined: resolver.ResolveNowOption
# github.com/coreos/etcd/clientv3/balancer/picker
C:\Users\jhinno\go\pkg\mod\github.com\coreos\etcd@v3.3.25+incompatible\clientv3\balancer\picker\err.go:37:44: undefined: balancer.PickOptions
C:\Users\jhinno\go\pkg\mod\github.com\coreos\etcd@v3.3.25+incompatible\clientv3\balancer\picker\roundrobin_balanced.go:55:54: undefined: balancer.PickOptions
报错原因
etc clientv3包的版本安装错误导致
错误解决
-
将
go.mod
文件中的grpc包版本进行更改
module go_code
go 1.15
require (
github.com/coreos/etcd v3.3.25+incompatible // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/gin-gonic/gin v1.6.3
github.com/go-sql-driver/mysql v1.5.0
github.com/gogo/protobuf v1.3.1 // indirect
github.com/jmoiron/sqlx v1.2.0
go.etcd.io/etcd v3.3.25+incompatible // indirect
go.uber.org/zap v1.16.0 // indirect
google.golang.org/grpc v1.33.2 // indirect 将这个版本降到v1.26.0
)
-
执行命令
go mod download
-
执行命令
go build
接着运行就好了
版权声明:本文为Aerkui原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。