Skip to content

A tool for auto converting go code into gRPC Protobuf file.

Notifications You must be signed in to change notification settings

tommady/grpcGen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grpcGen

A tool for auto converting go code into gRPC Protobuf file.

Pre-Install

  1. Go 1.5 or later
  2. gRPC
  3. gRPC-go

to get gRPC and gRPC-go just type:

$ go get google.golang.org/grpc
$ go get -a github.com/golang/protobuf/protoc-gen-go

Howto

simply type these in a go file:

package YourPackageName
//go:generate grpcGen $GOFILE

and then in terminal:

$ go generate

it will generated an example go code for you to modify. once you done the modification, then just type the same command as previous one in the terminal, it will generating an protobuf file and calling gRPC tool to generate an gRPC go code for you. THAT'S IT

Alt text

More Detail

There are three important symbol that will be referenced by grpcGen:

  1. @grpcGen:Message
  2. @grpcGen:Service
  3. @grpcGen:SrvName:

@grpcGen:Message

It is the Protobuf Message type, gRPC using this Message type for data communication.

Alt text

In here, you only need to define a go structure but with the message symbol @grpcGen:Message then grpcGen will parsing them into gRPC Message type for you and mark the go structure you defined as commends for letting others to understand our IN, OUT structure looks like!

Alt text

@grpcGen:Service and @grpcGen:SrvName:

It is the Protobuf Service type, gRPC using this Service type for defining open interface for letting other programs to call.

Alt text

In here, you have to define a go function with @grpcGen:Service and @grpcGen:SrvName: symbols.

Alt text

@grpcGen:SrvName: means the gRPC service name, of course you can defining two functions with the same SrvName, the grpcGen will auto parsing them into same service you named it!

About

A tool for auto converting go code into gRPC Protobuf file.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages