Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
add Walk in the example
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest Micklei committed Mar 12, 2018
1 parent 12fbf47 commit c9836c3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Package in Go for parsing Google Protocol Buffers [.proto files version 2 + 3] (
package main

import (
"fmt"
"os"

"github.com/emicklei/proto"
Expand All @@ -23,14 +24,27 @@ Package in Go for parsing Google Protocol Buffers [.proto files version 2 + 3] (
func main() {
reader, _ := os.Open("test.proto")
defer reader.Close()

parser := proto.NewParser(reader)
definition, _ := parser.Parse()
log.Println(definition)

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 contributions on top of this package such as protofmt, proto2xsd and proto2gql.
See (https://github.com/emicklei/proto-contrib) for other contributions on top of this package such as protofmt, proto2xsd and proto2gql.

#### known issues

Expand Down

0 comments on commit c9836c3

Please sign in to comment.