x1ongzhu 4750177287 first commit 7 yıl önce
..
BUILD.bazel 4750177287 first commit 7 yıl önce
LICENSE 4750177287 first commit 7 yıl önce
Makefile 4750177287 first commit 7 yıl önce
README.md 4750177287 first commit 7 yıl önce
comment.go 4750177287 first commit 7 yıl önce
enum.go 4750177287 first commit 7 yıl önce
extensions.go 4750177287 first commit 7 yıl önce
field.go 4750177287 first commit 7 yıl önce
go.mod 4750177287 first commit 7 yıl önce
group.go 4750177287 first commit 7 yıl önce
import.go 4750177287 first commit 7 yıl önce
message.go 4750177287 first commit 7 yıl önce
oneof.go 4750177287 first commit 7 yıl önce
option.go 4750177287 first commit 7 yıl önce
package.go 4750177287 first commit 7 yıl önce
parser.go 4750177287 first commit 7 yıl önce
proto.go 4750177287 first commit 7 yıl önce
range.go 4750177287 first commit 7 yıl önce
reserved.go 4750177287 first commit 7 yıl önce
service.go 4750177287 first commit 7 yıl önce
syntax.go 4750177287 first commit 7 yıl önce
token.go 4750177287 first commit 7 yıl önce
visitor.go 4750177287 first commit 7 yıl önce
walk.go 4750177287 first commit 7 yıl önce

README.md

proto

Build Status Go Report Card GoDoc

Package in Go for parsing Google Protocol Buffers .proto files version 2 + 3

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.