You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
7 years ago | |
|---|---|---|
| .. | ||
| BUILD.bazel | 7 years ago | |
| LICENSE | 7 years ago | |
| Makefile | 7 years ago | |
| README.md | 7 years ago | |
| comment.go | 7 years ago | |
| enum.go | 7 years ago | |
| extensions.go | 7 years ago | |
| field.go | 7 years ago | |
| go.mod | 7 years ago | |
| group.go | 7 years ago | |
| import.go | 7 years ago | |
| message.go | 7 years ago | |
| oneof.go | 7 years ago | |
| option.go | 7 years ago | |
| package.go | 7 years ago | |
| parser.go | 7 years ago | |
| proto.go | 7 years ago | |
| range.go | 7 years ago | |
| reserved.go | 7 years ago | |
| service.go | 7 years ago | |
| syntax.go | 7 years ago | |
| token.go | 7 years ago | |
| visitor.go | 7 years ago | |
| walk.go | 7 years ago | |
README.md
proto
Package in Go for parsing Google Protocol Buffers [.proto files version 2 + 3] (https://developers.google.com/protocol-buffers/docs/reference/proto3-spec)
install
go get -u -v 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) {
fmt.Println(m.Name)
}
contributions
See (https://github.com/emicklei/proto-contrib) for other contributions on top of this package such as protofmt, proto2xsd and proto2gql.
© 2017, ernestmicklei.com. MIT License. Contributions welcome.
