Package in Go for parsing Google Protocol Buffers [.proto files version 2 + 3] (https://developers.google.com/protocol-buffers/docs/reference/proto3-spec)
go get -u -v github.com/emicklei/proto
package main
import (
"os"
"github.com/emicklei/proto"
)
func main() {
reader, _ := os.Open("test.proto")
defer reader.Close()
parser := proto.NewParser(reader)
definition, _ := parser.Parse()
log.Println(definition)
}
See (https://github.com/emicklei/proto-contrib) for contributions on top of this package such as protofmt, proto2xsd and proto2gql.
- the proto2 test file in (https://github.com/emicklei/proto-contrib/cmd/protofmt) folder contains character escape sequences that are currently not accepted by the scanner. See line 537 and 573.
© 2017, ernestmicklei.com. MIT License. Contributions welcome.