reg/vendor/github.com/gogo/protobuf
Jess Frazelle 58cebbaa58
switch to new cli package and update generated files and deps
Signed-off-by: Jess Frazelle <acidburn@microsoft.com>
2018-07-15 17:48:35 -04:00
..
codec update deps 2018-07-14 11:48:41 -04:00
conformance switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
gogoproto switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
gogoreplace update deps 2018-07-14 11:48:41 -04:00
io update deps 2018-07-14 11:48:41 -04:00
jsonpb switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
plugin switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
proto switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
protobuf switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
protoc-gen-combo update deps 2018-07-14 11:48:41 -04:00
protoc-gen-gofast update deps 2018-07-14 11:48:41 -04:00
protoc-gen-gogo switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
protoc-gen-gogofast update deps 2018-07-14 11:48:41 -04:00
protoc-gen-gogofaster update deps 2018-07-14 11:48:41 -04:00
protoc-gen-gogoslick update deps 2018-07-14 11:48:41 -04:00
protoc-gen-gogotypes switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
protoc-gen-gostring update deps 2018-07-14 11:48:41 -04:00
protoc-min-version switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
sortkeys update deps 2018-07-14 11:48:41 -04:00
test switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
types switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
vanity switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
version update deps 2018-07-14 11:48:41 -04:00
.gitignore switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
.mailmap switch to dep 2017-12-11 14:50:55 -05:00
.travis.yml switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
AUTHORS switch to dep 2017-12-11 14:50:55 -05:00
bench.md switch to dep 2017-12-11 14:50:55 -05:00
CONTRIBUTORS update deps 2018-03-06 10:41:43 -05:00
custom_types.md switch to dep 2017-12-11 14:50:55 -05:00
extensions.md switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
GOLANG_CONTRIBUTORS switch to dep 2017-12-11 14:50:55 -05:00
install-protobuf.sh update deps 2018-03-06 10:41:43 -05:00
LICENSE switch to dep 2017-12-11 14:50:55 -05:00
Makefile switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
README switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00
Readme.md switch to new cli package and update generated files and deps 2018-07-15 17:48:35 -04:00

Protocol Buffers for Go with Gadgets

Build Status

gogoprotobuf is a fork of golang/protobuf with extra code generation features.

This code generation is used to achieve:

  • fast marshalling and unmarshalling
  • more canonical Go structures
  • goprotobuf compatibility
  • less typing by optionally generating extra helper code
  • peace of mind by optionally generating test and benchmark code
  • other serialization formats

Keeping track of how up to date gogoprotobuf is relative to golang/protobuf is done in this issue

Users

These projects use gogoprotobuf:

Please let us know if you are using gogoprotobuf by posting on our GoogleGroup.

Mentioned

Getting Started

There are several ways to use gogoprotobuf, but for all you need to install go and protoc. After that you can choose:

  • Speed
  • More Speed and more generated code
  • Most Speed and most customization

Installation

To install it, you must first have Go (at least version 1.6.3 or 1.9 if you are using gRPC) installed (see http://golang.org/doc/install). Latest patch versions of 1.9 and 1.10 are continuously tested.

Next, install the standard protocol buffer implementation from https://github.com/google/protobuf. Most versions from 2.3.1 should not give any problems, but 2.6.1, 3.0.2 and 3.5.1 are continuously tested.

Speed

Install the protoc-gen-gofast binary

go get github.com/gogo/protobuf/protoc-gen-gofast

Use it to generate faster marshaling and unmarshaling go code for your protocol buffers.

protoc --gofast_out=. myproto.proto

This does not allow you to use any of the other gogoprotobuf extensions.

More Speed and more generated code

Fields without pointers cause less time in the garbage collector. More code generation results in more convenient methods.

Other binaries are also included:

protoc-gen-gogofast (same as gofast, but imports gogoprotobuf)
protoc-gen-gogofaster (same as gogofast, without XXX_unrecognized, less pointer fields)
protoc-gen-gogoslick (same as gogofaster, but with generated string, gostring and equal methods)

Installing any of these binaries is easy. Simply run:

go get github.com/gogo/protobuf/proto
go get github.com/gogo/protobuf/{binary}
go get github.com/gogo/protobuf/gogoproto

These binaries allow you to use gogoprotobuf extensions. You can also use your own binary.

To generate the code, you also need to set the include path properly.

protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf/protobuf --{binary}_out=. myproto.proto

To use proto files from "google/protobuf" you need to add additional args to protoc.

protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf/protobuf --{binary}_out=\
Mgoogle/protobuf/any.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/duration.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types,\
Mgoogle/protobuf/wrappers.proto=github.com/gogo/protobuf/types:. \
myproto.proto

Note that in the protoc command, {binary} does not contain the initial prefix of "protoc-gen".

Most Speed and most customization

Customizing the fields of the messages to be the fields that you actually want to use removes the need to copy between the structs you use and structs you use to serialize. gogoprotobuf also offers more serialization formats and generation of tests and even more methods.

Please visit the extensions page for more documentation.

Install protoc-gen-gogo:

go get github.com/gogo/protobuf/proto
go get github.com/gogo/protobuf/jsonpb
go get github.com/gogo/protobuf/protoc-gen-gogo
go get github.com/gogo/protobuf/gogoproto

GRPC

It works the same as golang/protobuf, simply specify the plugin. Here is an example using gofast:

protoc --gofast_out=plugins=grpc:. my.proto

See https://github.com/gogo/grpc-example for an example of using gRPC with gogoprotobuf and the wider grpc-ecosystem.