Skip to content

sahansera/go-grpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

gRPC on Go

This projects you a start point for building a client and a server that communicates with gRPC. I also published a blog article series if you are interested.

Install πŸ—

Protobufs

brew instal protobuf

Go plugins for the protobuf compiler or refer here

make install

Invoking RPCs πŸš€

# Note: since we are not using TLS all the calls are with -plaintext flag
grpcurl -plaintext localhost:8080 list # introspect the service
grpcurl -plaintext localhost:8080 Inventory.GetBookList # to get a list of books

Useful commands πŸ“‘

Generate Go stubs

make gen

Clean stubs

make clean

Common issues and FAQ ❓

  1. VS Code complains about imports?

Known issue with the Proto3 VS Code plugin. Add the following to your settings.json file

"protoc": {
        "path": "/path/to/protoc",
        "compile_on_save": false,
        "options": [
            "--proto_path=protos/v3",
            "--proto_path=protos/v2",
            "--proto_path=${workspaceRoot}/proto",
            "--proto_path=${env.GOPATH}/src",
            "--java_out=gen/java"
        ]
    }

Run which protoc to find your proto compiler path.

  1. Auto formatter doesn't work?
brew install clang-format

Add the following to your settings.json

{
    // ...
    "editor.formatOnSave": true
    // ...
}