nknorg / nkn-sdk-go

Go implementation of NKN client and wallet
Apache License 2.0
58 stars 28 forks source link

add grpc example #95

Closed lochv closed 2 years ago

yilunzhang commented 2 years ago

When I tried to run the example, it gives me the following error:

examples/session/grpc/proto/hello_grpc.pb.go:11:2: missing go.sum entry for module providing package google.golang.org/grpc; to add:
    go mod download google.golang.org/grpc
examples/session/grpc/proto/hello_grpc.pb.go:12:2: missing go.sum entry for module providing package google.golang.org/grpc/codes (imported by github.com/nknorg/nkn-sdk-go/examples/session/grpc/proto); to add:
    go get github.com/nknorg/nkn-sdk-go/examples/session/grpc/proto
examples/session/grpc/proto/hello_grpc.pb.go:13:2: missing go.sum entry for module providing package google.golang.org/grpc/status (imported by github.com/nknorg/nkn-sdk-go/examples/session/grpc/proto); to add:
    go get github.com/nknorg/nkn-sdk-go/examples/session/grpc/proto

After I run go get github.com/nknorg/nkn-sdk-go/examples/session/grpc/proto and run example again, it throws another error:

# github.com/nknorg/nkn-sdk-go/examples/session/grpc/proto
proto/hello_grpc.pb.go:19:16: undefined: grpc.SupportPackageIsVersion7
proto/hello_grpc.pb.go:69:29: undefined: grpc.ServiceRegistrar

It could be a mismatch of grpc local version. What I think works best is that you create a go.mod and go.sum file in your example (and don't modify the project root go.mod/go.sum), and specify all the dependencies.

lochv commented 2 years ago

I added go mod

yilunzhang commented 2 years ago

Thanks for the contribution! Merged now