go-common/app/admin/ep/melloi/service/proto
2019-04-22 18:49:16 +08:00
..
BUILD.bazel Create & Init Project... 2019-04-22 18:49:16 +08:00
comment.go Create & Init Project... 2019-04-22 18:49:16 +08:00
enum.go Create & Init Project... 2019-04-22 18:49:16 +08:00
extensions.go Create & Init Project... 2019-04-22 18:49:16 +08:00
field.go Create & Init Project... 2019-04-22 18:49:16 +08:00
go.mod Create & Init Project... 2019-04-22 18:49:16 +08:00
group.go Create & Init Project... 2019-04-22 18:49:16 +08:00
import.go Create & Init Project... 2019-04-22 18:49:16 +08:00
LICENSE Create & Init Project... 2019-04-22 18:49:16 +08:00
Makefile Create & Init Project... 2019-04-22 18:49:16 +08:00
message.go Create & Init Project... 2019-04-22 18:49:16 +08:00
oneof.go Create & Init Project... 2019-04-22 18:49:16 +08:00
option.go Create & Init Project... 2019-04-22 18:49:16 +08:00
package.go Create & Init Project... 2019-04-22 18:49:16 +08:00
parser.go Create & Init Project... 2019-04-22 18:49:16 +08:00
proto.go Create & Init Project... 2019-04-22 18:49:16 +08:00
range.go Create & Init Project... 2019-04-22 18:49:16 +08:00
README.md Create & Init Project... 2019-04-22 18:49:16 +08:00
reserved.go Create & Init Project... 2019-04-22 18:49:16 +08:00
service.go Create & Init Project... 2019-04-22 18:49:16 +08:00
syntax.go Create & Init Project... 2019-04-22 18:49:16 +08:00
token.go Create & Init Project... 2019-04-22 18:49:16 +08:00
visitor.go Create & Init Project... 2019-04-22 18:49:16 +08:00
walk.go Create & Init Project... 2019-04-22 18:49:16 +08:00

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.