https://github.com/steadylearner/go-mod-with-grpc-example
How to use go mod with gRPC.(Could find the error from the outdated example.)
https://github.com/steadylearner/go-mod-with-grpc-example
go go-grpc-example go-grpc-examples go-mod go-mod-not-working-with-grpc go-mod-with-grpc go-module go-modules golang golang-grpc grpc grpc-go grpc-go-starter grpc-golang-example grpc-golang-examples grpc-golang-starter grpc-hello-world how-to-use-go-mod-with-grpc how-to-use-go-mod-with-grpc-example steadylearner
Last synced: about 1 year ago
JSON representation
How to use go mod with gRPC.(Could find the error from the outdated example.)
- Host: GitHub
- URL: https://github.com/steadylearner/go-mod-with-grpc-example
- Owner: steadylearner
- Created: 2020-03-19T13:07:54.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-19T19:18:04.000Z (about 6 years ago)
- Last Synced: 2025-01-11T02:32:56.803Z (about 1 year ago)
- Topics: go, go-grpc-example, go-grpc-examples, go-mod, go-mod-not-working-with-grpc, go-mod-with-grpc, go-module, go-modules, golang, golang-grpc, grpc, grpc-go, grpc-go-starter, grpc-golang-example, grpc-golang-examples, grpc-golang-starter, grpc-hello-world, how-to-use-go-mod-with-grpc, how-to-use-go-mod-with-grpc-example, steadylearner
- Language: Go
- Homepage: https://www.steadylearner.com/blog
- Size: 21.5 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to use go mod with gRPC
I followed [the official "hello world" example](https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_server/main.go) code. But, I couldn't make it work with go mod easily.
The major problem was this line. It is likely that the API was removed etc.
```console
In server/main.rs, comment this.
// pb.UnimplementedGreeterServer
```
I had to inspect what happend to "UnimplementedGreeterServer" by reading **pb** in helloworld/helloworld.pb.go. You can see that you can not find it there.
## How to reproduce working code example.
```console
$go mod init steadylearner.com/grpc
$go get github.com/golang/protobuf
$google.golang.org/grpc v1.28.0
```
Install what lack here if necessary. [You can refer to the GitHub page for it.](https://github.com/grpc/grpc-go)
Then, you can use this to build protobuf file.
```console
protoc -I helloworld/ helloworld/helloworld.proto --go_out=plugins=grpc:helloworld
```
Everything is ready. First, run gRPC server with **$go run main.rs** in current folder. Then, **$cd client && go run main.rs** in another kernel.
You will see **Received: world** at the server and **Greeting: Hello world** from the client.