my code
package main
import (
"context"
"log"
"github.com/coreos/etcd/clientv3"
etcdnaming "github.com/coreos/etcd/clientv3/naming"
"google.golang.org/grpc"
)
func main() {
cli, err := clientv3.NewFromURL("http://localhost:2379")
if err != nil {
log.Fatal(err)
}
r := &etcdnaming.GRPCResolver{Client: cli}
b := grpc.RoundRobin(r)
conn, err := grpc.Dial("user", grpc.WithInsecure(), grpc.WithBalancer(b))
if err != nil {
log.Fatal(err)
}
....
}
Issue
cannot use r (type *"github.com/coreos/etcd/clientv3/naming".GRPCResolver) as type "google.golang.org/grpc/naming".Resolver in argument to "google.golang.org/grpc".RoundRobin:
github.com/coreos/etcd/clientv3/naming".GRPCResolver does not implement "google.golang.org/grpc/naming".Resolver (wrong type for Resolve method)
have Resolve(string) ("github.com/coreos/etcd/vendor/google.golang.org/grpc/naming".Watcher, error)
want Resolve(string) ("google.golang.org/grpc/naming".Watcher, error)
hi @Wang-Kai per the Clientv3 get started guide
"For full compatibility, it is recommended to vendor builds using etcd's vendored packages, using tools like golang/dep"
To do this you need to install dep https://github.com/golang/dep and place your project code within $GOPATH/src.
So for example my $GOPATH looks like this /home/sam/go:/home/sam/dev/go
I create a project with your code example /home/sam/dev/go/src/clientv3/main.go
$ cd /home/sam/dev/go/src/clientv3
$ dep init
$ ls
Gopkg.lock Gopkg.toml main.go vendor
At this point you have a vendor folder with all the nessisary packages as well as a populated Gopkg.lock Gopkg.toml file. From here you can go build and it should work as expected. It is a few extra steps but once you used to it dep is a nice tool.
I hope that helps if this answers your question please close issue.
ref: https://github.com/golang/dep/blob/master/docs/new-project.md
@Wang-Kai Have you solved this problem?