- Issue
- Detail
- Cause
- @khenaidoo With the move to go.etcd.io/etcd, there are some (unavoidable?) dependency resolution issues:">@khenaidoo With the move to go.etcd.io/etcd, there are some (unavoidable?) dependency resolution issues:
- The identity crisis case:
- Related issues:
- Go vesrion
- Go Env
- Recent Changes in Go 1.13
- Solution
Issue
Install go-micro(µ)
Run following command
go get github.com/micro/go-micro
Detail
error info
weny@weny-server:~/Projects/Golang$ go install github.com/micro/go-micro
# github.com/micro/go-micro/transport/quic
src/github.com/micro/go-micro/transport/quic/quic.go:121:3: unknown field 'IdleTimeout' in struct literal of type quic.Config
# github.com/coreos/etcd/clientv3
src/github.com/coreos/etcd/clientv3/auth.go:121:72: cannot use auth.callOpts (type []"github.com/coreos/etcd/vendor/google.golang.org/grpc".CallOption) as type []"go.etcd.io/etcd/vendor/google.golang.org/grpc".CallOption in argument to auth.remote.AuthEnable
src/github.com/coreos/etcd/clientv3/auth.go:126:74: cannot use auth.callOpts (type []"github.com/coreos/etcd/vendor/google.golang.org/grpc".CallOption) as type []"go.etcd.io/etcd/vendor/google.golang.org/grpc".CallOption in argument to auth.remote.AuthDisable
src/github.com/coreos/etcd/clientv3/auth.go:131:152: cannot use auth.callOpts (type []"github.com/coreos/etcd/vendor/google.golang.org/grpc".CallOption) as type []"go.etcd.io/etcd/vendor/google.golang.org/grpc".CallOption in argument to auth.remote.UserAdd
src/github.com/coreos/etcd/clientv3/auth.go:136:144: cannot use auth.callOpts (type []"github.com/coreos/etcd/vendor/google.golang.org/grpc".CallOption) as type []"go.etcd.io/etcd/vendor/google.golang.org/grpc".CallOption in argument to auth.remote.UserAdd
src/github.com/coreos/etcd/clientv3/auth.go:141:86: cannot use auth.callOpts (type []"github.com/coreos/etcd/vendor/google.golang.org/grpc".CallOption) as type []"go.etcd.io/etcd/vendor/google.golang.org/grpc".CallOption in argument to auth.remote.UserDelete
src/github.com/coreos/etcd/clientv3/auth.go:146:122: cannot use auth.callOpts (type []"github.com/coreos/etcd/vendor/google.golang.org/grpc".CallOption) as type []"go.etcd.io/etcd/vendor/google.golang.org/grpc".CallOption in argument to auth.remote.UserChangePassword
src/github.com/coreos/etcd/clientv3/auth.go:151:104: cannot use auth.callOpts (type []"github.com/coreos/etcd/vendor/google.golang.org/grpc".CallOption) as type []"go.etcd.io/etcd/vendor/google.golang.org/grpc".CallOption in argument to auth.remote.UserGrantRole
src/github.com/coreos/etcd/clientv3/auth.go:156:80: cannot use auth.callOpts (type []"github.com/coreos/etcd/vendor/google.golang.org/grpc".CallOption) as type []"go.etcd.io/etcd/vendor/google.golang.org/grpc".CallOption in argument to auth.remote.UserGet
src/github.com/coreos/etcd/clientv3/auth.go:161:72: cannot use auth.callOpts (type []"github.com/coreos/etcd/vendor/google.golang.org/grpc".CallOption) as type []"go.etcd.io/etcd/vendor/google.golang.org/grpc".CallOption in argument to auth.remote.UserList
src/github.com/coreos/etcd/clientv3/auth.go:166:106: cannot use auth.callOpts (type []"github.com/coreos/etcd/vendor/google.golang.org/grpc".CallOption) as type []"go.etcd.io/etcd/vendor/google.golang.org/grpc".CallOption in argument to auth.remote.UserRevokeRole
src/github.com/coreos/etcd/clientv3/auth.go:166:106: too many errors
Cause
@khenaidoo With the move to go.etcd.io/etcd, there are some (unavoidable?) dependency resolution issues:
The identity crisis case:
github automatically creates redirects for project moves, so
github.com/coreos/etcdnow redirects togithub.com/etcd-io/etcd, which means that if you depend ongithub.com/coreos/etcdon master, or the git hash of this PR or newer, you’re dependency manager (orgo get) will pull code fromgithub.com/coreos/etcd(following the redirect togithub.com/etcd-io/etcd) and pull down etcd source that contains imports togo.etcd.io/etcdpackages, but it will think the code is for thegithub.com/coreos/etcdand so it will believe that thegithub.com/etcd-io/etcdimports are to a different project. I believe the dependency manger (orgo get) will then also pull in thego.etcd.io/etcdproject since it saw import statements for it, which means you’ve got two copies of etcd in your dependencies with import statements between them, resulting in error messages like you’ve shown.Possible fixes:
- Depend on a released etcd version (git tags like v3.3.9) instead of master since all released versions reference
coreos/etcdin imports and will work just fine.- If one needs to depend on master, explicitly update all import statements to
go.etcd.io/etcdand verify there are no direct or transitive dependencies remain forgithub.com/coreos/etcd.
ref:https://github.com/etcd-io/etcd/pull/10044#issuecomment-417125341
Related issues:
*: rename import paths to “go.etcd.io/etcd”
#10044<br />[https://github.com/etcd-io/etcd/pull/10044#issuecomment-417125341](https://github.com/etcd-io/etcd/pull/10044#issuecomment-417125341)<br />/etcd/clientv3 cannot use auth.callOpts (type
#870<br />[https://github.com/micro/go-micro/issues/870](https://github.com/micro/go-micro/issues/870)
Go vesrion
go version go1.13.5 linux/amd64
Go Env
root@571f03ab64ad:~# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build666438605=/tmp/go-build -gno-record-gcc-switches"
Recent Changes in Go 1.13
The
GO111MODULEenvironment variable continues to default toauto, but theautosetting now activates the module-aware mode of thegocommand whenever the current working directory contains, or is below a directory containing, ago.modfile — even if the current directory is withinGOPATH/src. This change simplifies the migration of existing code withinGOPATH/srcand the ongoing maintenance of module-aware packages alongside non-module-aware importers.
ref:https://tip.golang.org/doc/go1.13#modules
GO111MODULE=autoenables module-mode if any go.mod is found, even inside GOPATH. (Prior to Go 1.13,GO111MODULE=autowould never enable module-mode inside GOPATH).
ref:https://github.com/golang/go/wiki/Modules
Solution
Point( in this case )
By default (GO111MODULE=auto),enabling module-mode depends on if any go.mod is foundGO111MODULE does not default to on
Fix
set the GO111MODULE environment variableexport GO111MODULE=on
if Need
rungo clean -modcache
