{"repo":"emicklei/proto","free":true,"listed":false,"github":"https://github.com/emicklei/proto","clone":"git clone https://github.com/emicklei/proto.git","description":"parser for Google ProtocolBuffers definition","language":"Go","stars":614,"topics":["protobuf","parser","proto3","formatter","proto2","golang-package","protocol-buffers","protobuf-parser"],"license":"MIT","category":"dev-tools","readme_excerpt":"proto Package in Go for parsing Google Protocol Buffers .proto files version 2 + 3, editions install go get github.com/emicklei/proto usage package main import ( \"fmt\" \"os\" \"github.com/emicklei/proto\" ) func main() { reader, := os.Open(\"test.proto\") defer reader.Close() parser := proto.NewParser(reader) definition, := parser.Parse() proto.Walk(definition, proto.WithService(handleService), proto.WithMessage(handleMessage)) } func handleService(s proto.Service) { fmt.Println(s.Name) } func handleMessage(m proto.Message) { lister := new(optionLister) for , each := range m.Elements { each.Accept(lister) } fmt.Println(m.Name) } type optionLister struct { proto.NoopVisitor } func (l optionLister) VisitOption(o proto.Option) { fmt.Println(o.Name) } validation Current parser implementation is not completely validating .proto definitions. In many but not all cases, the parser will report syntax errors when reading unexpected charaters or tokens. Use some linting tools or protoc for full validation. contributions See proto-contrib for other contributions on top of this package such as protofmt, proto2xsd and proto2gql. protobuf2map is a small package for inspecting serialized protobuf messages using its .proto definition. © 2017-2025, ernestmicklei.com. MIT License. Contributions welcome.","default_branch":null,"files":null,"tree":[],"storefront":"/r/emicklei","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/emicklei/proto/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}