proto

parser for Google ProtocolBuffers definition

Github星跟踪图

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)
}

validation

Current parser implementation is not completely validating .proto definitions.
In many but not all cases, the parser will report syntax errors when reading unexpected charaters or tokens.
Use some linting tools (e.g. https://github.com/uber/prototool) or protoc for full validation.

contributions

See proto-contrib for other contributions on top of this package such as protofmt, proto2xsd and proto2gql.
protobuf2map is a small package for inspecting serialized protobuf messages using its .proto definition.

© 2017, ernestmicklei.com. MIT License. Contributions welcome.

主要指标

概览
名称与所有者emicklei/proto
主编程语言Go
编程语言Go (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2017-01-26 21:30:48
推送于2024-12-18 12:28:02
最后一次提交2024-12-18 13:23:41
发布数50
最新版本名称v1.14.0 (发布于 2024-12-18 13:28:01)
第一版名称proto2xsd-0.2 (发布于 2017-07-12 06:06:00)
用户参与
星数601
关注者数10
派生数67
提交数245
已启用问题?
问题数78
打开的问题数0
拉请求数61
打开的拉请求数0
关闭的拉请求数8
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?