package proto
import "github.com/emicklei/proto"
Index ¶
- type Comment
- func (c *Comment) Accept(v Visitor)
- func (c *Comment) Merge(other *Comment)
- func (c Comment) Message() string
- func (c *Comment) String() string
- type Documented
- type Enum
- type EnumField
- type Extensions
- type Field
- type Formatter
- func NewFormatter(writer io.Writer, indentSeparator string) *Formatter
- func (f *Formatter) Format(p *Proto)
- func (f *Formatter) VisitComment(c *Comment)
- func (f *Formatter) VisitEnum(e *Enum)
- func (f *Formatter) VisitEnumField(e *EnumField)
- func (f *Formatter) VisitExtensions(e *Extensions)
- func (f *Formatter) VisitGroup(g *Group)
- func (f *Formatter) VisitImport(i *Import)
- func (f *Formatter) VisitMapField(m *MapField)
- func (f *Formatter) VisitMessage(m *Message)
- func (f *Formatter) VisitNormalField(f1 *NormalField)
- func (f *Formatter) VisitOneof(o *Oneof)
- func (f *Formatter) VisitOneofField(o *OneOfField)
- func (f *Formatter) VisitOption(o *Option)
- func (f *Formatter) VisitPackage(p *Package)
- func (f *Formatter) VisitRPC(r *RPC)
- func (f *Formatter) VisitReserved(r *Reserved)
- func (f *Formatter) VisitService(s *Service)
- func (f *Formatter) VisitSyntax(s *Syntax)
- type Group
- type Import
- type Literal
- type MapField
- type Message
- func (m *Message) Accept(v Visitor)
- func (m *Message) Doc() *Comment
- func (m *Message) String() string
- type NamedLiteral
- type NormalField
- func (f *NormalField) Accept(v Visitor)
- func (f *NormalField) Doc() *Comment
- func (n *NormalField) String() string
- type OneOfField
- type Oneof
- type Option
- type Package
- type Parser
- func NewParser(r io.Reader) *Parser
- func (p *Parser) Filename(f string)
- func (p *Parser) Parse() (*Proto, error)
- type Proto
- type RPC
- type Range
- type Reserved
- type Service
- type Syntax
- type Visitee
- type Visitor
Types ¶
type Comment ¶
type Comment struct { Position scanner.Position Lines []string Cstyle bool // refers to /* ... */, C++ style is using // ExtraSlash bool }
Comment holds a message.
func (*Comment) Accept ¶
Accept dispatches the call to the visitor.
func (*Comment) Merge ¶
Merge appends all lines from the argument comment.
func (Comment) Message ¶
Message returns the first line or empty if no lines.
func (*Comment) String ¶
type Documented ¶
type Documented interface { Doc() *Comment }
Documented is for types that may have an associated comment (not inlined).
type Enum ¶
Enum definition consists of a name and an enum body.
func (*Enum) Accept ¶
Accept dispatches the call to the visitor.
func (*Enum) Doc ¶
Doc is part of Documented
type EnumField ¶
type EnumField struct { Position scanner.Position Comment *Comment Name string Integer int ValueOption *Option InlineComment *Comment }
EnumField is part of the body of an Enum.
func (*EnumField) Accept ¶
Accept dispatches the call to the visitor.
func (*EnumField) Doc ¶
Doc is part of Documented
type Extensions ¶
type Extensions struct { Position scanner.Position Comment *Comment Ranges []Range InlineComment *Comment }
Extensions declare that a range of field numbers in a message are available for third-party extensions. proto2 only
func (*Extensions) Accept ¶
func (e *Extensions) Accept(v Visitor)
Accept dispatches the call to the visitor.
func (*Extensions) String ¶
func (e *Extensions) String() string
type Field ¶
type Field struct { Position scanner.Position Comment *Comment Name string Type string Sequence int Options []*Option InlineComment *Comment }
Field is an abstract message field.
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter visits a Proto and writes formatted source.
func NewFormatter ¶
NewFormatter returns a new Formatter. Only the indentation separator is configurable.
func (*Formatter) Format ¶
Format visits all proto elements and writes formatted source.
func (*Formatter) VisitComment ¶
VisitComment formats a Comment and writes a newline.
func (*Formatter) VisitEnum ¶
VisitEnum formats a Enum.
func (*Formatter) VisitEnumField ¶
VisitEnumField formats a EnumField.
func (*Formatter) VisitExtensions ¶
func (f *Formatter) VisitExtensions(e *Extensions)
VisitExtensions formats a proto2 Extensions.
func (*Formatter) VisitGroup ¶
VisitGroup formats a proto2 Group.
func (*Formatter) VisitImport ¶
VisitImport formats a Import.
func (*Formatter) VisitMapField ¶
VisitMapField formats a MapField.
func (*Formatter) VisitMessage ¶
VisitMessage formats a Message.
func (*Formatter) VisitNormalField ¶
func (f *Formatter) VisitNormalField(f1 *NormalField)
VisitNormalField formats a NormalField.
func (*Formatter) VisitOneof ¶
VisitOneof formats a Oneof.
func (*Formatter) VisitOneofField ¶
func (f *Formatter) VisitOneofField(o *OneOfField)
VisitOneofField formats a OneofField.
func (*Formatter) VisitOption ¶
VisitOption formats a Option.
func (*Formatter) VisitPackage ¶
VisitPackage formats a Package.
func (*Formatter) VisitRPC ¶
VisitRPC formats a RPC.
func (*Formatter) VisitReserved ¶
VisitReserved formats a Reserved.
func (*Formatter) VisitService ¶
VisitService formats a Service.
func (*Formatter) VisitSyntax ¶
VisitSyntax formats a Syntax.
type Group ¶
type Group struct { Position scanner.Position Comment *Comment Name string Optional bool Sequence int Elements []Visitee }
Group represents a (proto2 only) group. https://developers.google.com/protocol-buffers/docs/reference/proto2-spec#group_field
func (*Group) Accept ¶
Accept dispatches the call to the visitor.
func (*Group) Doc ¶
Doc is part of Documented
func (*Group) String ¶
type Import ¶
type Import struct { Position scanner.Position Comment *Comment Filename string Kind string // weak, public, <empty> InlineComment *Comment }
Import holds a filename to another .proto definition.
func (*Import) Accept ¶
Accept dispatches the call to the visitor.
func (*Import) Doc ¶
Doc is part of Documented
type Literal ¶
Literal represents intLit,floatLit,strLit or boolLit
func (Literal) String ¶
String returns the source (if quoted then use double quote).
type MapField ¶
MapField represents a map entry in a message.
func (*MapField) Accept ¶
Accept dispatches the call to the visitor.
type Message ¶
type Message struct { Position scanner.Position Comment *Comment Name string IsExtend bool Elements []Visitee }
Message consists of a message name and a message body.
func (*Message) Accept ¶
Accept dispatches the call to the visitor.
func (*Message) Doc ¶
Doc is part of Documented
func (*Message) String ¶
type NamedLiteral ¶
NamedLiteral associates a name with a Literal
type NormalField ¶
NormalField represents a field in a Message.
func (*NormalField) Accept ¶
func (f *NormalField) Accept(v Visitor)
Accept dispatches the call to the visitor.
func (*NormalField) Doc ¶
func (f *NormalField) Doc() *Comment
Doc is part of Documented
func (*NormalField) String ¶
func (n *NormalField) String() string
type OneOfField ¶
type OneOfField struct { *Field }
OneOfField is part of Oneof.
func (*OneOfField) Accept ¶
func (o *OneOfField) Accept(v Visitor)
Accept dispatches the call to the visitor.
func (*OneOfField) Doc ¶
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 ¶
Oneof is a field alternate.
func (*Oneof) Accept ¶
Accept dispatches the call to the visitor.
type Option ¶
type Option struct { Position scanner.Position Comment *Comment Name string Constant Literal IsEmbedded bool AggregatedConstants []*NamedLiteral InlineComment *Comment }
Option is a protoc compiler option
func (*Option) Accept ¶
Accept dispatches the call to the visitor.
func (*Option) Doc ¶
Doc is part of Documented
type Package ¶
type Package struct { Position scanner.Position Comment *Comment Name string InlineComment *Comment }
Package specifies the namespace for all proto elements.
func (*Package) Accept ¶
Accept dispatches the call to the visitor.
func (*Package) Doc ¶
Doc is part of Documented
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents a parser.
func NewParser ¶
NewParser returns a new instance of Parser.
func (*Parser) Filename ¶
Filename is for reporting. Optional.
func (*Parser) Parse ¶
Parse parses a proto definition. May return a parse or scanner error.
type Proto ¶
type Proto struct { Elements []Visitee }
Proto represents a .proto definition
type RPC ¶
type RPC struct { Position scanner.Position Comment *Comment Name string RequestType string StreamsRequest bool ReturnsType string StreamsReturns bool Options []*Option InlineComment *Comment }
RPC represents an rpc entry in a message.
func (*RPC) Accept ¶
Accept dispatches the call to the visitor.
func (*RPC) Doc ¶
Doc is part of Documented
type Range ¶
Range is to specify number intervals (with special end value "max")
func (Range) String ¶
String return a single number if from = to. Returns <from> to <to> otherwise unless Max then return <from> to max.
type Reserved ¶
type Reserved struct { Position scanner.Position Comment *Comment Ranges []Range FieldNames []string InlineComment *Comment }
Reserved statements declare a range of field numbers or field names that cannot be used in a message.
func (*Reserved) Accept ¶
Accept dispatches the call to the visitor.
type Service ¶
Service defines a set of RPC calls.
func (*Service) Accept ¶
Accept dispatches the call to the visitor.
func (*Service) Doc ¶
Doc is part of Documented
type Syntax ¶
type Syntax struct { Position scanner.Position Comment *Comment Value string InlineComment *Comment }
Syntax should have value "proto"
func (*Syntax) Accept ¶
Accept dispatches the call to the visitor.
func (*Syntax) Doc ¶
Doc is part of Documented
type Visitee ¶
type Visitee interface { Accept(v Visitor) }
Visitee is implemented by all Proto elements.
type Visitor ¶
type Visitor interface { 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.
Source Files ¶
aligned.go comment.go enum.go extensions.go field.go formatter.go formatter_utils.go group.go import.go message.go oneof.go option.go package.go parser.go proto.go range.go reserved.go service.go syntax.go token.go visitor.go
Directories ¶
Path | Synopsis |
---|---|
cmd | |
cmd/proto2gql | |
cmd/proto2xsd | |
cmd/protofmt |
- Version
- v1.1.0
- Published
- Nov 30, 2017
- Platform
- js/wasm
- Imports
- 8 packages
- Last checked
- now –
Tools for package owners.