Protocol Buffers for Go with Gadgets
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
codec Authors file and consistent licensing Jul 28, 2016
conformance merged in golang/protobuf commit 7011d38ac0d201eeddff4a4085a657c3da32… Dec 30, 2018
gogoproto merged in golang/protobuf commit 7011d38ac0d201eeddff4a4085a657c3da32… Dec 30, 2018
gogoreplace generated proto types Aug 24, 2016
io use only one write in the varint writer when possible (#504) Nov 16, 2018
jsonpb merged in golang/protobuf commit 7011d38ac0d201eeddff4a4085a657c3da32… Dec 30, 2018
plugin Codegen for well-known types (#489) Oct 26, 2018
proto merged in golang/protobuf commit 951a149f90371fb8858c6c979d03bb258361… Dec 30, 2018
protobuf update to protoc 3.6.1 (#534) Dec 31, 2018
protoc-gen-combo options to not generate xxx fields (#467) Aug 29, 2018
protoc-gen-gofast Authors file and consistent licensing Jul 28, 2016
protoc-gen-gogo update to protoc 3.6.1 (#534) Dec 31, 2018
protoc-gen-gogofast merge Aug 24, 2016
protoc-gen-gogofaster options to not generate xxx fields (#467) Aug 29, 2018
protoc-gen-gogoslick options to not generate xxx fields (#467) Aug 29, 2018
protoc-gen-gogotypes Added ProtoSize wrapper functions for the well known types #438 (#443) Aug 1, 2018
protoc-gen-gostring protoc-gen-gostring Aug 20, 2016
protoc-min-version protoc-min-version don't suppress protoc stdout and stderr out on suc… Feb 15, 2018
sortkeys Authors file and consistent licensing Jul 28, 2016
test update to protoc 3.6.1 (#534) Dec 31, 2018
types update to protoc 3.6.1 (#534) Dec 31, 2018
vanity merged in golang/protobuf commit 7011d38ac0d201eeddff4a4085a657c3da32… Dec 30, 2018
version Fix typo (#441) Jul 30, 2018
.gitignore dev: conformance: clean up, fix conformance tests - merge ab964bf6033… Apr 8, 2018
.mailmap added contributors Mar 4, 2016
.travis.yml update to protoc 3.6.1 (#534) Dec 31, 2018
AUTHORS Fix a race when using TextMarshal on a StdDuration (#290) Aug 4, 2017
CONTRIBUTORS Update to protobuf 3.5.1 and minor cleanups for Golang 1.10 (#363) Jan 2, 2018
GOLANG_CONTRIBUTORS added contributors Mar 4, 2016
LICENSE merge in golang/protobuf commit 668a607657a5d387d6333648a2d9c749761fd… Aug 10, 2018
Makefile merged in golang/protobuf commit 93b26e6a70e37abb14f2f88194949312b059… Dec 11, 2018
README merged in golang/protobuf commit 89a0c16f4dc2a70c0ed864d8ef64878f24fd… Dec 11, 2018
Readme.md update readme to reflect new golang and protoc versions (#535) Dec 31, 2018
bench.md moving docs into the repo Aug 21, 2016
custom_types.md Customtype Warnings and issues update (#479) Sep 14, 2018
extensions.md options to not generate xxx fields (#467) Aug 29, 2018
go.mod merged in golang/protobuf commit ebb3f5824e60ab924d5a647fdc09b85d87c2… Dec 30, 2018
go.sum merged in golang/protobuf commit ebb3f5824e60ab924d5a647fdc09b85d87c2… Dec 30, 2018
install-protobuf.sh Update to protobuf 3.5.1 and minor cleanups for Golang 1.10 (#363) Jan 2, 2018

Readme.md

Protocol Buffers for Go with Gadgets

Build Status GoDoc

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.10 and 1.11 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.6.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.

License

This software is licensed under the 3-Clause BSD License ("BSD License 2.0", "Revised BSD License", "New BSD License", or "Modified BSD License").