import "github.com/emicklei/proto"
comment.go enum.go extensions.go field.go group.go import.go message.go oneof.go option.go package.go parent_accessor.go parser.go proto.go range.go reserved.go service.go syntax.go token.go visitor.go walk.go
Walk recursively pays a visit to all Visitees of a Proto and calls each handler with it.
type Comment struct { Position scanner.Position // Lines are comment text lines without prefixes //, ///, /* or suffix */ Lines []string Cstyle bool // refers to /* ... */, C++ style is using // ExtraSlash bool // is true if the comment starts with 3 slashes }
Comment one or more comment text lines, either in c- or c++ style.
Accept dispatches the call to the visitor.
Merge appends all lines from the argument comment.
Message returns the first line or empty if no lines.
Documented is for types that may have an associated comment (not inlined).
type Enum struct { Position scanner.Position Comment *Comment Name string Elements []Visitee Parent Visitee }
Enum definition consists of a name and an enum body.
Accept dispatches the call to the visitor.
Doc is part of Documented
type EnumField struct { Position scanner.Position Comment *Comment Name string Integer int // ValueOption is deprecated, use Elements instead ValueOption *Option Elements []Visitee // such as Option and Comment InlineComment *Comment Parent Visitee }
EnumField is part of the body of an Enum.
Accept dispatches the call to the visitor.
Doc is part of Documented
type Extensions struct { Position scanner.Position Comment *Comment Ranges []Range InlineComment *Comment Parent Visitee }
Extensions declare that a range of field numbers in a message are available for third-party extensions. proto2 only
func (e *Extensions) Accept(v Visitor)
Accept dispatches the call to the visitor.
type Field struct { Position scanner.Position Comment *Comment Name string Type string Sequence int Options []*Option InlineComment *Comment Parent Visitee }
Field is an abstract message field.
type Group struct { Position scanner.Position Comment *Comment Name string Optional bool Repeated bool Required bool Sequence int Elements []Visitee Parent Visitee }
Group represents a (proto2 only) group. https://developers.google.com/protocol-buffers/docs/reference/proto2-spec#group_field
Accept dispatches the call to the visitor.
Doc is part of Documented
Handler is a type of function that accepts a Visitee.
WithEnum returns a Handler that will call the apply function when the Visitee is a Enum.
WithImport returns a Handler that will call the apply function when the Visitee is an Import.
WithMessage returns a Handler that will call the apply function when the Visitee is a Message.
WithOneof returns a Handler that will call the apply function when the Visitee is a Oneof.
WithOption returns a Handler that will call the apply function when the Visitee is a Option.
WithPackage returns a Handler that will call the apply function when the Visitee is a Package.
WithRPC returns a Handler that will call the apply function when the Visitee is a RPC.
WithService returns a Handler that will call the apply function when the Visitee is a Service.
type Import struct { Position scanner.Position Comment *Comment Filename string Kind string // weak, public, <empty> InlineComment *Comment Parent Visitee }
Import holds a filename to another .proto definition.
Accept dispatches the call to the visitor.
Doc is part of Documented
type Literal struct { Position scanner.Position Source string IsString bool // The rune use to delimit the string value (only valid iff IsString) QuoteRune rune // literal value can be an array literal value (even nested) Array []*Literal // literal value can be a map of literals (even nested) // DEPRECATED: use OrderedMap instead Map map[string]*Literal // literal value can be a map of literals (even nested) // this is done as pairs of name keys and literal values so the original ordering is preserved OrderedMap LiteralMap }
Literal represents intLit,floatLit,strLit or boolLit or a nested structure thereof.
SourceRepresentation returns the source (use the same rune that was used to delimit the string).
type LiteralMap []*NamedLiteral
LiteralMap is like a map of *Literal but preserved the ordering. Can be iterated yielding *NamedLiteral values.
func (m LiteralMap) Get(key string) (*Literal, bool)
Get returns a Literal from the map.
MapField represents a map entry in a message.
Accept dispatches the call to the visitor.
type Message struct { Position scanner.Position Comment *Comment Name string IsExtend bool Elements []Visitee Parent Visitee }
Message consists of a message name and a message body.
Accept dispatches the call to the visitor.
Doc is part of Documented
type NamedLiteral struct { *Literal Name string // PrintsColon is true when the Name must be printed with a colon suffix PrintsColon bool }
NamedLiteral associates a name with a Literal
NormalField represents a field in a Message.
func (f *NormalField) Accept(v Visitor)
Accept dispatches the call to the visitor.
func (f *NormalField) Doc() *Comment
Doc is part of Documented
OneOfField is part of Oneof.
func (o *OneOfField) Accept(v Visitor)
Accept dispatches the call to the visitor.
func (o *OneOfField) Doc() *Comment
Doc is part of Documented Note: although Doc() is defined on Field, it must be implemented here as well.
type Oneof struct { Position scanner.Position Comment *Comment Name string Elements []Visitee Parent Visitee }
Oneof is a field alternate.
Accept dispatches the call to the visitor.
Doc is part of Documented
type Option struct { Position scanner.Position Comment *Comment Name string Constant Literal IsEmbedded bool // AggregatedConstants is DEPRECATED. These Literals are populated into Constant.OrderedMap AggregatedConstants []*NamedLiteral InlineComment *Comment Parent Visitee }
Option is a protoc compiler option
Accept dispatches the call to the visitor.
Doc is part of Documented
type Package struct { Position scanner.Position Comment *Comment Name string InlineComment *Comment Parent Visitee }
Package specifies the namespace for all proto elements.
Accept dispatches the call to the visitor.
Doc is part of Documented
type Parser struct {
// contains filtered or unexported fields
}
Parser represents a parser.
NewParser returns a new instance of Parser.
Filename is for reporting. Optional.
Parse parses a proto definition. May return a parse or scanner error.
Proto represents a .proto definition
Accept dispatches the call to the visitor.
type RPC struct { Position scanner.Position Comment *Comment Name string RequestType string StreamsRequest bool ReturnsType string StreamsReturns bool Elements []Visitee InlineComment *Comment Parent Visitee // Options field is DEPRECATED, use Elements instead. Options []*Option }
RPC represents an rpc entry in a message.
Accept dispatches the call to the visitor.
Doc is part of Documented
Range is to specify number intervals (with special end value "max")
SourceRepresentation return a single number if from = to. Returns <from> to <to> otherwise unless Max then return <from> to max.
type Reserved struct { Position scanner.Position Comment *Comment Ranges []Range FieldNames []string InlineComment *Comment Parent Visitee }
Reserved statements declare a range of field numbers or field names that cannot be used in a message.
Accept dispatches the call to the visitor.
type Service struct { Position scanner.Position Comment *Comment Name string Elements []Visitee Parent Visitee }
Service defines a set of RPC calls.
Accept dispatches the call to the visitor.
Doc is part of Documented
type Syntax struct { Position scanner.Position Comment *Comment Value string InlineComment *Comment Parent Visitee }
Syntax should have value "proto"
Accept dispatches the call to the visitor.
Doc is part of Documented
Visitee is implemented by all Proto elements.
type Visitor interface { //VisitProto(p *Proto) VisitMessage(m *Message) VisitService(v *Service) VisitSyntax(s *Syntax) VisitPackage(p *Package) VisitOption(o *Option) VisitImport(i *Import) VisitNormalField(i *NormalField) VisitEnumField(i *EnumField) VisitEnum(e *Enum) VisitComment(e *Comment) VisitOneof(o *Oneof) VisitOneofField(o *OneOfField) VisitReserved(r *Reserved) VisitRPC(r *RPC) VisitMapField(f *MapField) // proto2 VisitGroup(g *Group) VisitExtensions(e *Extensions) }
Visitor is for dispatching Proto elements.
Package proto imports 9 packages (graph) and is imported by 31 packages. Updated 2020-05-26. Refresh now. Tools for package owners.