• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D28-Aug-201952

.travis.ymlH A D28-Aug-201945

CHANGES.mdH A D28-Aug-2019101

LICENSEH A D28-Aug-20191 KiB

MakefileH A D28-Aug-20191.8 KiB

README.mdH A D28-Aug-20191.7 KiB

comment.goH A D28-Aug-20194.6 KiB

comment_test.goH A D28-Aug-20198.3 KiB

enum.goH A D28-Aug-20195 KiB

enum_test.goH A D28-Aug-20194.5 KiB

extensions.goH A D28-Aug-20191.9 KiB

extensions_test.goH A D28-Aug-20192 KiB

field.goH A D28-Aug-20194.5 KiB

field_test.goH A D28-Aug-20195.8 KiB

go.modH A D28-Aug-201942

group.goH A D28-Aug-20192.8 KiB

group_test.goH A D28-Aug-20192.1 KiB

import.goH A D28-Aug-20192.1 KiB

import_test.goH A D28-Aug-20191.5 KiB

message.goH A D28-Aug-20195.8 KiB

message_test.goH A D28-Aug-20194.3 KiB

oneof.goH A D28-Aug-20193.8 KiB

oneof_test.goH A D28-Aug-20194.1 KiB

option.goH A D28-Aug-201910 KiB

option_test.goH A D28-Aug-201920.3 KiB

package.goH A D28-Aug-20191.9 KiB

package_test.goH A D28-Aug-20191.4 KiB

parent_accessor.goH A D28-Aug-20192.6 KiB

parent_test.goH A D28-Aug-20193.7 KiB

parser.goH A D28-Aug-20196.8 KiB

parser_test.goH A D28-Aug-20194.2 KiB

proto.goH A D28-Aug-20194.7 KiB

protobuf_test.goH A D28-Aug-2019991

range.goH A D28-Aug-20192.6 KiB

range_test.goH A D28-Aug-20192.2 KiB

reserved.goH A D28-Aug-20192.3 KiB

reserved_test.goH A D28-Aug-20192.1 KiB

service.goH A D28-Aug-20196.2 KiB

service_test.goH A D28-Aug-20195.6 KiB

syntax.goH A D28-Aug-20191.9 KiB

syntax_test.goH A D28-Aug-20191.4 KiB

token.goH A D28-Aug-20194.7 KiB

token_test.goH A D28-Aug-20191.9 KiB

visitor.goH A D28-Aug-20191.9 KiB

visitor_test.goH A D28-Aug-20191.9 KiB

walk.goH A D28-Aug-20192.9 KiB

walk_test.goH A D28-Aug-2019629

README.md

1# proto
2
3[![Build Status](https://travis-ci.org/emicklei/proto.png)](https://travis-ci.org/emicklei/proto)
4[![Go Report Card](https://goreportcard.com/badge/github.com/emicklei/proto)](https://goreportcard.com/report/github.com/emicklei/proto)
5[![GoDoc](https://godoc.org/github.com/emicklei/proto?status.svg)](https://godoc.org/github.com/emicklei/proto)
6
7Package in Go for parsing Google Protocol Buffers [.proto files version 2 + 3] (https://developers.google.com/protocol-buffers/docs/reference/proto3-spec)
8
9### install
10
11    go get -u -v github.com/emicklei/proto
12
13### usage
14
15	package main
16
17	import (
18		"fmt"
19		"os"
20
21		"github.com/emicklei/proto"
22	)
23
24	func main() {
25		reader, _ := os.Open("test.proto")
26		defer reader.Close()
27
28		parser := proto.NewParser(reader)
29		definition, _ := parser.Parse()
30
31		proto.Walk(definition,
32			proto.WithService(handleService),
33			proto.WithMessage(handleMessage))
34	}
35
36	func handleService(s *proto.Service) {
37		fmt.Println(s.Name)
38	}
39
40	func handleMessage(m *proto.Message) {
41		fmt.Println(m.Name)
42	}
43
44### validation
45
46Current parser implementation is not completely validating `.proto` definitions.
47In many but not all cases, the parser will report syntax errors when reading unexpected charaters or tokens.
48Use some linting tools (e.g. https://github.com/uber/prototool) or `protoc` for full validation.
49
50### contributions
51
52See [proto-contrib](https://github.com/emicklei/proto-contrib) for other contributions on top of this package such as protofmt, proto2xsd and proto2gql.
53[protobuf2map](https://github.com/emicklei/protobuf2map) is a small package for inspecting serialized protobuf messages using its `.proto` definition.
54
55© 2017, [ernestmicklei.com](http://ernestmicklei.com).  MIT License. Contributions welcome.