protoc-gen-defaults

command module
v0.0.0-...-dff7951 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2018 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

protoc-gen-defaults

Generates base implementation for gRPC services that allows to add methods to gRPC services without breaking existing builds.

Example

Lets take a simple proto file like below,

service EchoService {
    rpc Echo(EchoRequest) returns (EchoResponse);
}

This will generate a file containing this,

// BaseEchoServiceServer is the dummy implementation of the EchoServiceServer. Embed this into your own implementation
// to add new methods without breaking builds.
type BaseEchoServiceServer struct{}

// Echo is an unimplemented form of the method Echo
func (BaseEchoServiceServer) Echo(context.Context, *EchoRequest) (*EchoResponse, error) {
	return nil, status.Error(codes.Unimplemented, codes.Unimplemented.String())
}

It can then be used like this, Embed into your implementation.

type server struct {
    pb.BaseEchoServiceServer	
}

Now server implements EchoServiceServer.

How to use it?

Just go get it and it will add the plugin to your path,

go get -u github.com/srikrsna/protoc-gen-defaults

Then use the plugin like below,

protoc -I ./example --defaults_out=:./example ./example/example.proto

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址