bilibili-backup/app/admin/ep/melloi/service/proto
2019-04-22 02:59:20 +00:00
..
BUILD.bazel init 2019-04-22 02:59:20 +00:00
comment.go init 2019-04-22 02:59:20 +00:00
enum.go init 2019-04-22 02:59:20 +00:00
extensions.go init 2019-04-22 02:59:20 +00:00
field.go init 2019-04-22 02:59:20 +00:00
go.mod init 2019-04-22 02:59:20 +00:00
group.go init 2019-04-22 02:59:20 +00:00
import.go init 2019-04-22 02:59:20 +00:00
LICENSE init 2019-04-22 02:59:20 +00:00
Makefile init 2019-04-22 02:59:20 +00:00
message.go init 2019-04-22 02:59:20 +00:00
oneof.go init 2019-04-22 02:59:20 +00:00
option.go init 2019-04-22 02:59:20 +00:00
package.go init 2019-04-22 02:59:20 +00:00
parser.go init 2019-04-22 02:59:20 +00:00
proto.go init 2019-04-22 02:59:20 +00:00
range.go init 2019-04-22 02:59:20 +00:00
README.md init 2019-04-22 02:59:20 +00:00
reserved.go init 2019-04-22 02:59:20 +00:00
service.go init 2019-04-22 02:59:20 +00:00
syntax.go init 2019-04-22 02:59:20 +00:00
token.go init 2019-04-22 02:59:20 +00:00
visitor.go init 2019-04-22 02:59:20 +00:00
walk.go init 2019-04-22 02:59:20 +00: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.