Documentation ¶
Overview ¶
Package protobuf contains structures to represent a protobuf definition, and tools to create textual representation of the definition.
Index ¶
- Variables
- type Builtin
- type Container
- type Encoder
- func (e *Encoder) Encode(v interface{}) error
- func (e *Encoder) EncodeEnum(v *Enum) error
- func (e *Encoder) EncodeExtension(ext *Extension) error
- func (e *Encoder) EncodeExtensionField(f *ExtensionField) error
- func (e *Encoder) EncodeField(v *Field) error
- func (e *Encoder) EncodeGlobalOption(o *GlobalOption) error
- func (e *Encoder) EncodeHTTPAnnotation(a *HTTPAnnotation) error
- func (e *Encoder) EncodeMessage(v *Message) error
- func (e *Encoder) EncodePackage(p *Package) error
- func (e *Encoder) EncodeRPC(r *RPC) error
- func (e *Encoder) EncodeRPCOption(v interface{}) error
- func (e *Encoder) EncodeService(s *Service) error
- func (e *Encoder) EncodeType(v Type) error
- type Enum
- type Extension
- type ExtensionField
- type Field
- type GlobalOption
- type HTTPAnnotation
- type Map
- type Message
- type Option
- type Package
- type RPC
- type RPCOption
- type Reference
- type ResolveFunc
- type Service
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( BoolType = newBuiltin("bool") BytesType = newBuiltin("bytes") DoubleType = newBuiltin("double") FloatType = newBuiltin("float") Int32Type = newBuiltin("int32") Int64Type = newBuiltin("int64") StringType = newBuiltin("string") )
Builtin types
var ( AnyType = NewMessage("google.protobuf.Any") BoolValueType = NewMessage("google.protobuf.BoolValue") BytesValueType = NewMessage("google.protobuf.BytesValue") DoubleValueType = NewMessage("google.protobuf.DoubleValue") FloatValueType = NewMessage("google.protobuf.FloatValue") Int32ValueType = NewMessage("google.protobuf.Int32Value") Int64ValueType = NewMessage("google.protobuf.Int64Value") NullValueType = NewMessage("google.protobuf.NullValue") StringValueType = NewMessage("google.protobuf.StringValue") )
Boxed types
var (
ListValueType = NewMessage("google.protobuf.ListValue")
)
list type
var (
StructType = NewMessage("google.protobuf.Struct")
)
value type
Functions ¶
This section is empty.
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is responsible for taking a protobuf.Package object and encodes it into textual representation
func NewEncoder ¶
NewEncoder creates an Encoder object that writes the encoded Protocol Buffers declaration to `dst`
func (*Encoder) EncodeEnum ¶
EncodeEnum encodes an Enum object
func (*Encoder) EncodeExtension ¶
EncodeExtension encodes an Extension object
func (*Encoder) EncodeExtensionField ¶
func (e *Encoder) EncodeExtensionField(f *ExtensionField) error
EncodeExtensionField encodes an ExtensionField object
func (*Encoder) EncodeField ¶
EncodeField encods the message field
func (*Encoder) EncodeGlobalOption ¶
func (e *Encoder) EncodeGlobalOption(o *GlobalOption) error
EncodeGlobalOption encodes a GlobationOption object
func (*Encoder) EncodeHTTPAnnotation ¶
func (e *Encoder) EncodeHTTPAnnotation(a *HTTPAnnotation) error
EncodeHTTPAnnotation encods a HTTPAnnotation object
func (*Encoder) EncodeMessage ¶
EncodeMessage encodes a Message object
func (*Encoder) EncodePackage ¶
EncodePackage encodes a Package
func (*Encoder) EncodeRPCOption ¶
EncodeRPCOption encodes RPC options
func (*Encoder) EncodeService ¶
EncodeService encodes a Service object
func (*Encoder) EncodeType ¶
EncodeType detected Package, Enum, Message, Service, and Extension types and encodes them
type Enum ¶
type Enum struct {
// contains filtered or unexported fields
}
Enum represents a Protocol Buffers enum type
func (*Enum) AddElement ¶
func (e *Enum) AddElement(n interface{})
AddElement adds a new enum element
func (*Enum) SetComment ¶
SetComment sets the comment associated with this enum
type Extension ¶
type Extension struct {
// contains filtered or unexported fields
}
Extension represents an extended message
func NewExtension ¶
NewExtension creates an Extension object
func (*Extension) AddField ¶
func (e *Extension) AddField(f *ExtensionField)
AddField adds an ExtensionField
type ExtensionField ¶
type ExtensionField struct {
// contains filtered or unexported fields
}
ExtensionField is a field in an extended field
func NewExtensionField ¶
func NewExtensionField(name, typ string, number int) *ExtensionField
NewExtensionField creates an ExtensionField object
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
Field is a field in a Message
func (*Field) SetComment ¶
SetComment sets the comment associated to this field
func (*Field) SetRepeated ¶
SetRepeated sets if this field can be repeated
type GlobalOption ¶
type GlobalOption struct {
// contains filtered or unexported fields
}
GlobalOption represents a Protocol Buffers global option
func NewGlobalOption ¶
func NewGlobalOption(name, value string) *GlobalOption
NewGlobalOption creates a GlobalOption
func (*GlobalOption) Name ¶
func (o *GlobalOption) Name() string
Name returns the name of the GlobalOption
func (*GlobalOption) Value ¶
func (o *GlobalOption) Value() string
Value returns the value of the GlobalOption
type HTTPAnnotation ¶
type HTTPAnnotation struct {
// contains filtered or unexported fields
}
HTTPAnnotation represents a google.api.http option
func NewHTTPAnnotation ¶
func NewHTTPAnnotation(method, path string) *HTTPAnnotation
NewHTTPAnnotation creates an HTTPAnnotation object
func (*HTTPAnnotation) SetBody ¶
func (a *HTTPAnnotation) SetBody(s string)
SetBody sets the body optional parameter
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map represents a Protocol Buffers map type
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is a composite type
func (*Message) SetComment ¶
SetComment sets the comment associated to this message
type Option ¶
Option is used to pass options to several methods
func WithIndent ¶
WithIndent creates a new Option to control the indentation for the encoded definition
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package represnets a Protocol Buffers Package.
func (*Package) AddOption ¶
func (p *Package) AddOption(t *GlobalOption)
AddOption adds a global option
type RPC ¶
type RPC struct {
// contains filtered or unexported fields
}
RPC represents an RPC call associated with a Service
func (*RPC) AddOption ¶
func (r *RPC) AddOption(v interface{})
AddOption adds rpc options to the RPC
func (*RPC) SetParameter ¶
SetParameter sets the parameter type
type RPCOption ¶
type RPCOption struct {
// contains filtered or unexported fields
}
RPCOption represents simple rpc options
func NewRPCOption ¶
NewRPCOption create an RPCOption object
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
Reference is a special type of Type that can pass the protobuf.Type system, but requires that it be resolved at runtime to get the actual Type behind it. This is used to resolve circular dependencies that are found during compilation phase
type ResolveFunc ¶
ResolveFunc is the function used to resolve `$ref` strings to an actual protobuf.Type
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service defines a service with many RPC endpoints