This repository has been archived by the owner. It is now read-only.
No description, website, or topics provided.
Clone or download
Pull request Compare This branch is 14 commits behind emicklei:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml
LICENSE
Makefile
README.md
comment.go
comment_test.go
enum.go
enum_test.go
extensions.go
extensions_test.go
field.go
field_test.go
group.go
group_test.go
import.go
import_test.go
message.go
message_test.go
oneof.go
oneof_test.go
option.go
option_test.go
package.go
parent_accessor.go
parent_test.go
parser.go
parser_test.go
proto.go
protobuf_test.go
range.go
range_test.go
reserved.go
reserved_test.go
service.go
service_test.go
syntax.go
syntax_test.go
token.go
visitor.go
visitor_test.go
walk.go
walk_test.go

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.