MCPcopy
hub / github.com/gogo/protobuf

github.com/gogo/protobuf @v1.3.2 sqlite

repository ↗ · DeepWiki ↗ · release v1.3.2 ↗
32,598 symbols 120,278 edges 462 files 814 documented · 2%
README

GoGo Protobuf looking for new ownership

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

Release v1.3.0

The project has updated to release v1.3.0. Check out the release notes here.

With this new release comes a new internal library version. This means any newly generated pb.go files generated with the v1.3.0 library will not be compatible with the old library version (v1.2.1). However, current pb.go files (generated with v1.2.1) should still work with the new library.

Please make sure you manage your dependencies correctly when upgrading your project. If you are still using v1.2.1 and you update your dependencies, one of which could include a new *pb.go (generated with v1.3.0), you could get a compile time error.

Our upstream repo, golang/protobuf, also had to go through this process in order to update their library version. Here is a link explaining hermetic builds.

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.12 and 1.15 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.14.0 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").

Extension points exported contracts — how you extend this code

Message (Interface)
Message is implemented by generated protocol buffer messages. [748 implementers]
proto/lib.go
Marshaler (Interface)
Marshaler is the interface representing objects that can marshal themselves. [338 implementers]
proto/encode.go
Unmarshaler (Interface)
Unmarshaler is the interface representing objects that can unmarshal themselves. The argument points to data that may b [340 …
proto/decode.go
Message (Interface)
Message is a proto.Message with a method to return its descriptor. Message types generated by the protocol compiler alw [748 …
protoc-gen-gogo/descriptor/descriptor.go
JSONPBMarshaler (Interface)
JSONPBMarshaler is implemented by protobuf messages that customize the way they are marshaled to JSON. Messages that imp [7 …
jsonpb/jsonpb.go
TestPlugin (Interface)
(no doc) [28 implementers]
plugin/testgen/testgen.go
Sizer (Interface)
(no doc) [819 implementers]
proto/lib_gogo.go
Plugin (Interface)
A Plugin provides functionality to add to the output during Go code generation, such as to produce RPC stubs. [4 implementers]
protoc-gen-gogo/generator/generator.go

Core symbols most depended-on inside this repo

Marshal
called by 3211
codec/codec.go
Unmarshal
called by 3159
codec/codec.go
P
called by 2166
protoc-gen-gogo/grpc/grpc.go
UnmarshalText
called by 1000
test/issue411/ids.go
Intn
called by 896
test/custom/custom.go
RegisterType
called by 759
proto/properties.go
Merge
called by 746
proto/clone.go
DiscardUnknown
called by 745
proto/discard.go

Shape

Method 21,174
Function 9,551
Struct 1,237
Interface 513
TypeAlias 117
FuncType 6

Languages

Go100%

Modules by API surface

test/combos/both/thetest.pb.go2,410 symbols
test/combos/marshaler/thetest.pb.go2,341 symbols
test/combos/unmarshaler/thetest.pb.go2,205 symbols
test/thetest.pb.go2,136 symbols
test/combos/marshaler/thetestpb_test.go954 symbols
test/combos/both/thetestpb_test.go954 symbols
test/thetestpb_test.go886 symbols
test/combos/unmarshaler/thetestpb_test.go886 symbols
proto/test_proto/test.pb.go748 symbols
test/types/combos/both/types.pb.go540 symbols
test/types/combos/marshaler/types.pb.go530 symbols
test/types/combos/unmarshaler/types.pb.go466 symbols

Dependencies from manifests, versioned

github.com/kisielk/gotoolv1.0.0 · 1×
golang.org/x/toolsv0.0.0-2021010621484 · 1×

For agents

$ claude mcp add protobuf \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact