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.
 
 
 
root beccf3fe43 init 7 years ago
..
BUILD.bazel init 7 years ago
LICENSE init 7 years ago
Makefile init 7 years ago
README.md init 7 years ago
comment.go init 7 years ago
enum.go init 7 years ago
extensions.go init 7 years ago
field.go init 7 years ago
go.mod init 7 years ago
group.go init 7 years ago
import.go init 7 years ago
message.go init 7 years ago
oneof.go init 7 years ago
option.go init 7 years ago
package.go init 7 years ago
parser.go init 7 years ago
proto.go init 7 years ago
range.go init 7 years ago
reserved.go init 7 years ago
service.go init 7 years ago
syntax.go init 7 years ago
token.go init 7 years ago
visitor.go init 7 years ago
walk.go init 7 years ago

README.md

proto

Build Status Go Report Card GoDoc

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.