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

Commit

Permalink
doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest Micklei authored and Ernest Micklei committed Feb 1, 2017
1 parent 394737f commit 34001c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.org/emicklei/proto.png)](https://travis-ci.org/emicklei/proto)
[![GoDoc](https://godoc.org/github.com/emicklei/proto?status.svg)](https://godoc.org/github.com/emicklei/proto)

Package in Go for parsing Google Protocol Buffers [.proto files version 2 + 3] (https://developers.google.com/protocol-buffers/docs/reference/proto-spec)
Package in Go for parsing and formatting Google Protocol Buffers [.proto files version 2 + 3] (https://developers.google.com/protocol-buffers/docs/reference/proto-spec)

### usage

Expand Down
10 changes: 7 additions & 3 deletions visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ type Visitee interface {
Accept(v Visitor)
}

// reflector is a Visitor that can tell the short type name of a Visitee.
type reflector struct {
name string
}

// sole instance of reflector
var namer = new(reflector)

func (r *reflector) VisitMessage(m *Message) { r.name = "Message" }
func (r *reflector) VisitService(v *Service) { r.name = "Service" }
func (r *reflector) VisitSyntax(s *Syntax) { r.name = "Syntax" }
Expand All @@ -44,8 +48,8 @@ func (r *reflector) VisitReserved(rs *Reserved) { r.name = "Reserved" }
func (r *reflector) VisitRPC(rpc *RPC) { r.name = "RPC" }
func (r *reflector) VisitMapField(f *MapField) { r.name = "MapField" }

// nameOfVisitee returns the short type name of a Visitee.
func nameOfVisitee(e Visitee) string {
r := new(reflector)
e.Accept(r)
return r.name
e.Accept(namer)
return namer.name
}

0 comments on commit 34001c2

Please sign in to comment.