Documentation ¶
Index ¶
- func FormatCode(filename string, buffer []byte) []byte
- func GetFieldMappedProtoOption(field *desc.FieldDescriptorProto) bool
- func GetGoPackage(url string) string
- func GetGoPath(url string) string
- func NewPrinterProxy(printer *Printer) *printerProxy
- func OneOrZero(hp handlerParams) string
- func P(args ...string) string
- func WriteClientStreaming(printer *Printer, params *handlerParams, isSql bool) error
- func WriteHandlers(p *Printer, s *Service) (outErr error)
- func WriteHooks(p *Printer, s *Service) error
- func WriteImports(p *Printer, f *FileStruct) error
- func WriteIters(p *Printer, s *Service) (outErr error)
- func WritePackageLevelDeclarations(p *Printer, files *FileList) error
- func WritePersistServerStruct(printer *Printer, service, db string) error
- func WriteQueries(p *Printer, s *Service) error
- func WriteRows(p *Printer, s *Service) (outErr error)
- func WriteServerStream(printer *Printer, params *handlerParams, isSql bool) error
- func WriteTypeMappings(p *Printer, s *Service) error
- func WriteUnary(printer *Printer, params *handlerParams, isSql bool) error
- type FileList
- type FileStruct
- func (f *FileStruct) DifferentImpl() bool
- func (f *FileStruct) Generate() ([]byte, error)
- func (f *FileStruct) GetFileName() string
- func (f *FileStruct) GetFullGoPackage() string
- func (f *FileStruct) GetGoPackage() string
- func (f *FileStruct) GetGoPath() string
- func (f *FileStruct) GetGoTypeName(typ string) string
- func (f *FileStruct) GetImplDir() string
- func (f *FileStruct) GetImplFileName(sourceRelative bool) string
- func (f *FileStruct) GetImplPackage() string
- func (f *FileStruct) GetOrigName() string
- func (f *FileStruct) GetPackageName() string
- func (f *FileStruct) GetPersistFile() string
- func (f *FileStruct) GetPersistPackageOption() string
- func (f *FileStruct) GetServices() *Services
- func (f *FileStruct) IsSameAsMyPackage(pkg string) bool
- func (f *FileStruct) NeedImport(pkg string) bool
- func (f *FileStruct) NotSameAsMyPackage(pkg string) bool
- func (f *FileStruct) Process() error
- func (f *FileStruct) ProcessImports()
- func (f *FileStruct) ProcessImportsForType(name string)
- func (f *FileStruct) SanatizeImports()
- type Generator
- type GeneratorStruct
- type GenericDescriptor
- type HasLabelAndType
- type Import
- type Imports
- type Match
- func (Match) AfterHook(mopt *MethodProtoOpts) bool
- func (Match) BeforeHook(mopt *MethodProtoOpts) bool
- func (Match) BidiStreaming(mopt *MethodProtoOpts) bool
- func (Match) ClientStreaming(mopt *MethodProtoOpts) bool
- func (m *Match) EachMethod(do func(*MethodProtoOpts), matches ...func(*MethodProtoOpts) bool)
- func (m *Match) EachMethodIn(do func(*desc.FieldDescriptorProto, *MethodProtoOpts), ...)
- func (m *Match) EachMethodOut(do func(*desc.FieldDescriptorProto, *MethodProtoOpts), ...)
- func (m *Match) EachQuery(do func(*QueryProtoOpts), matches ...func(*QueryProtoOpts) bool)
- func (m *Match) EachQueryIn(do func(*desc.FieldDescriptorProto, *QueryProtoOpts), ...)
- func (m *Match) EachQueryOut(do func(*desc.FieldDescriptorProto, *QueryProtoOpts), ...)
- func (m *Match) EachTM(do func(*TypeMappingProtoOpts), matches ...func(*TypeMappingProtoOpts) bool)
- func (m *Match) Err() error
- func (Match) FilterFieldNames(names []string) func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool
- func (Match) MatchMethod(mopt *MethodProtoOpts) func(*QueryProtoOpts) bool
- func (Match) MatchQuery(opt *QueryProtoOpts) func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool
- func (Match) MatchQueryInField(f *desc.FieldDescriptorProto) func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool
- func (Match) MatchQueryName(opt *QueryProtoOpts) func(*MethodProtoOpts) bool
- func (Match) MatchQueryOutField(f *desc.FieldDescriptorProto) func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool
- func (Match) MatchTypeMapping(f *desc.FieldDescriptorProto) func(*TypeMappingProtoOpts) bool
- func (Match) MatchingFieldNames(names []string) func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool
- func (Match) QueryFieldFitsDB(field *desc.FieldDescriptorProto, q *QueryProtoOpts) bool
- func (m Match) QueryFieldIsMapped(field *desc.FieldDescriptorProto, q *QueryProtoOpts) bool
- func (Match) QueryFieldIsMessage(field *desc.FieldDescriptorProto, q *QueryProtoOpts) bool
- func (Match) QueryFieldIsRepeated(field *desc.FieldDescriptorProto, q *QueryProtoOpts) bool
- func (Match) QueryFieldScannedAsInt64(field *desc.FieldDescriptorProto, q *QueryProtoOpts) bool
- func (Match) ServerStreaming(mopt *MethodProtoOpts) bool
- func (Match) Unary(mopt *MethodProtoOpts) bool
- type MethodProtoOpts
- type PersistOpts
- type Printer
- type QueryProtoOpts
- type Service
- func (s *Service) GetName() string
- func (s *Service) GetQueriesOption() *persist.QueryOpts
- func (s *Service) GetServiceType() *persist.PersistenceOptions
- func (s *Service) GetTypeMapping() *persist.TypeMapping
- func (s *Service) GetUndoctoredQueryByName(queryName string) (*persist.QLImpl, error)
- func (s *Service) IsSQL() bool
- func (s *Service) IsSpanner() bool
- type Services
- type Struct
- func (s *Struct) GetFieldDescriptorsIfMessage() ([]*desc.FieldDescriptorProto, bool)
- func (s *Struct) GetFieldType(field string) *desc.FieldDescriptorProto
- func (s *Struct) GetGoName() string
- func (s *Struct) GetGoPath() string
- func (s *Struct) GetImportedFiles() *FileList
- func (s *Struct) GetProtoName() string
- type StructList
- func (s *StructList) AddEnum(enum *desc.EnumDescriptorProto, parent *Struct, pkg string, file *FileStruct) *Struct
- func (s *StructList) AddMessage(message *desc.DescriptorProto, parent *Struct, pkg string, file *FileStruct) *Struct
- func (s *StructList) Append(struc *Struct)
- func (s *StructList) GetStructByFieldDesc(fld *desc.FieldDescriptorProto) *Struct
- func (s *StructList) GetStructByName(name string) *Struct
- func (s *StructList) GetStructByProtoName(name string) *Struct
- type TmAsField
- type TypeMappingProtoOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCode ¶
func GetFieldMappedProtoOption ¶
func GetFieldMappedProtoOption(field *desc.FieldDescriptorProto) bool
returns if this field was marked as always needing a type mapping
func GetGoPackage ¶
GetGoPackage get a go import url under the following formats github.com/path/project/dir;package github.com/path/project/dir project/dir;package project/dir and will return the package name from url package dir package dir
func GetGoPath ¶
GetGoPath get a go import url under the following formats github.com/path/project/dir;package github.com/path/project/dir project/dir;package project/dir and will return the path portion from url: github.com/path/project/dir project/dir
func NewPrinterProxy ¶
func NewPrinterProxy(printer *Printer) *printerProxy
func WriteClientStreaming ¶
func WriteHandlers ¶
func WriteHooks ¶
func WriteImports ¶
func WriteImports(p *Printer, f *FileStruct) error
BUG:: ONLY WORKS WITH sql.DB, needs to work with spanner
func WriteIters ¶
func WriteQueries ¶
func WriteServerStream ¶
func WriteTypeMappings ¶
func WriteUnary ¶
Types ¶
type FileList ¶
type FileList []*FileStruct
func NewFileList ¶
func NewFileList() *FileList
func (*FileList) Append ¶
func (fl *FileList) Append(file *FileStruct)
func (*FileList) FindFile ¶
func (fl *FileList) FindFile(desc *descriptor.FileDescriptorProto) *FileStruct
func (*FileList) GetOrCreateFile ¶
func (fl *FileList) GetOrCreateFile(desc *descriptor.FileDescriptorProto, allStructs *StructList, dependency bool, params PersistOpts) *FileStruct
type FileStruct ¶
type FileStruct struct { Desc *descriptor.FileDescriptorProto ImportList *Imports Dependency bool // if is dependency Structures *StructList // all structures in the file AllStructures *StructList // all structures in all the files ServiceList *Services Opts PersistOpts // options passed in via parameter }
func NewFileStruct ¶
func NewFileStruct( desc *descriptor.FileDescriptorProto, allStructs *StructList, dependency bool, opts PersistOpts) *FileStruct
func (*FileStruct) DifferentImpl ¶
func (f *FileStruct) DifferentImpl() bool
func (*FileStruct) Generate ¶
func (f *FileStruct) Generate() ([]byte, error)
func (*FileStruct) GetFileName ¶
func (f *FileStruct) GetFileName() string
func (*FileStruct) GetFullGoPackage ¶
func (f *FileStruct) GetFullGoPackage() string
func (*FileStruct) GetGoPackage ¶
func (f *FileStruct) GetGoPackage() string
func (*FileStruct) GetGoPath ¶
func (f *FileStruct) GetGoPath() string
func (*FileStruct) GetGoTypeName ¶
func (f *FileStruct) GetGoTypeName(typ string) string
func (*FileStruct) GetImplDir ¶
func (f *FileStruct) GetImplDir() string
func (*FileStruct) GetImplFileName ¶
func (f *FileStruct) GetImplFileName(sourceRelative bool) string
func (*FileStruct) GetImplPackage ¶
func (f *FileStruct) GetImplPackage() string
func (*FileStruct) GetOrigName ¶
func (f *FileStruct) GetOrigName() string
func (*FileStruct) GetPackageName ¶
func (f *FileStruct) GetPackageName() string
func (*FileStruct) GetPersistFile ¶
func (f *FileStruct) GetPersistFile() string
return the computed persist file taking in consideration the persist.package option and original file name
func (*FileStruct) GetPersistPackageOption ¶
func (f *FileStruct) GetPersistPackageOption() string
extract the persist.package file option or return "" as default
func (*FileStruct) GetServices ¶
func (f *FileStruct) GetServices() *Services
func (*FileStruct) IsSameAsMyPackage ¶
func (f *FileStruct) IsSameAsMyPackage(pkg string) bool
func (*FileStruct) NeedImport ¶
func (f *FileStruct) NeedImport(pkg string) bool
func (*FileStruct) NotSameAsMyPackage ¶
func (f *FileStruct) NotSameAsMyPackage(pkg string) bool
func (*FileStruct) Process ¶
func (f *FileStruct) Process() error
func (*FileStruct) ProcessImports ¶
func (f *FileStruct) ProcessImports()
func (*FileStruct) ProcessImportsForType ¶
func (f *FileStruct) ProcessImportsForType(name string)
func (*FileStruct) SanatizeImports ¶
func (f *FileStruct) SanatizeImports()
type Generator ¶
type Generator struct { OriginalRequest *plugin_go.CodeGeneratorRequest AllStructures *StructList // all structures present in the files Files *FileList Response *plugin_go.CodeGeneratorResponse SourceRelative bool }
func NewGenerator ¶
func NewGenerator(request *plugin_go.CodeGeneratorRequest) *Generator
func (*Generator) CommandLineParameters ¶
func (*Generator) GetResponse ¶
func (g *Generator) GetResponse() (*plugin_go.CodeGeneratorResponse, error)
type GeneratorStruct ¶
type GeneratorStruct interface {
Generate() string
}
type GenericDescriptor ¶
type GenericDescriptor interface {
GetName() string
}
type HasLabelAndType ¶
type HasLabelAndType interface { GetLabel() descriptor.FieldDescriptorProto_Label GetType() descriptor.FieldDescriptorProto_Type GetTypeName() string }
type Imports ¶
type Imports []*Import
func EmptyImportList ¶
func EmptyImportList() *Imports
func (*Imports) GetGoNameByStruct ¶
func (*Imports) GetImportPkgForPath ¶
func (*Imports) GetOrAddImport ¶
type Match ¶
type Match struct {
// contains filtered or unexported fields
}
func (Match) AfterHook ¶
func (Match) AfterHook(mopt *MethodProtoOpts) bool
func (Match) BeforeHook ¶
func (Match) BeforeHook(mopt *MethodProtoOpts) bool
func (Match) BidiStreaming ¶
func (Match) BidiStreaming(mopt *MethodProtoOpts) bool
func (Match) ClientStreaming ¶
func (Match) ClientStreaming(mopt *MethodProtoOpts) bool
func (*Match) EachMethod ¶
func (m *Match) EachMethod(do func(*MethodProtoOpts), matches ...func(*MethodProtoOpts) bool)
func (*Match) EachMethodIn ¶
func (m *Match) EachMethodIn(do func(*desc.FieldDescriptorProto, *MethodProtoOpts), matches ...func(*desc.FieldDescriptorProto, *MethodProtoOpts) bool)
func (*Match) EachMethodOut ¶
func (m *Match) EachMethodOut(do func(*desc.FieldDescriptorProto, *MethodProtoOpts), matches ...func(*desc.FieldDescriptorProto, *MethodProtoOpts) bool)
func (*Match) EachQuery ¶
func (m *Match) EachQuery(do func(*QueryProtoOpts), matches ...func(*QueryProtoOpts) bool)
func (*Match) EachQueryIn ¶
func (m *Match) EachQueryIn(do func(*desc.FieldDescriptorProto, *QueryProtoOpts), matches ...func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool)
func (*Match) EachQueryOut ¶
func (m *Match) EachQueryOut(do func(*desc.FieldDescriptorProto, *QueryProtoOpts), matches ...func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool)
func (*Match) EachTM ¶
func (m *Match) EachTM(do func(*TypeMappingProtoOpts), matches ...func(*TypeMappingProtoOpts) bool)
func (Match) FilterFieldNames ¶
func (Match) FilterFieldNames(names []string) func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool
func (Match) MatchMethod ¶
func (Match) MatchMethod(mopt *MethodProtoOpts) func(*QueryProtoOpts) bool
func (Match) MatchQuery ¶
func (Match) MatchQuery(opt *QueryProtoOpts) func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool
func (Match) MatchQueryInField ¶
func (Match) MatchQueryInField(f *desc.FieldDescriptorProto) func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool
func (Match) MatchQueryName ¶
func (Match) MatchQueryName(opt *QueryProtoOpts) func(*MethodProtoOpts) bool
func (Match) MatchQueryOutField ¶
func (Match) MatchQueryOutField(f *desc.FieldDescriptorProto) func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool
func (Match) MatchTypeMapping ¶
func (Match) MatchTypeMapping(f *desc.FieldDescriptorProto) func(*TypeMappingProtoOpts) bool
func (Match) MatchingFieldNames ¶
func (Match) MatchingFieldNames(names []string) func(*desc.FieldDescriptorProto, *QueryProtoOpts) bool
func (Match) QueryFieldFitsDB ¶
func (Match) QueryFieldFitsDB(field *desc.FieldDescriptorProto, q *QueryProtoOpts) bool
func (Match) QueryFieldIsMapped ¶
func (m Match) QueryFieldIsMapped(field *desc.FieldDescriptorProto, q *QueryProtoOpts) bool
func (Match) QueryFieldIsMessage ¶
func (Match) QueryFieldIsMessage(field *desc.FieldDescriptorProto, q *QueryProtoOpts) bool
func (Match) QueryFieldIsRepeated ¶
func (Match) QueryFieldIsRepeated(field *desc.FieldDescriptorProto, q *QueryProtoOpts) bool
func (Match) QueryFieldScannedAsInt64 ¶
func (Match) QueryFieldScannedAsInt64(field *desc.FieldDescriptorProto, q *QueryProtoOpts) bool
func (Match) ServerStreaming ¶
func (Match) ServerStreaming(mopt *MethodProtoOpts) bool
func (Match) Unary ¶
func (Match) Unary(mopt *MethodProtoOpts) bool
type MethodProtoOpts ¶
type MethodProtoOpts struct {
// contains filtered or unexported fields
}
func NewMethodProtoOpts ¶
func NewMethodProtoOpts(opt *desc.MethodDescriptorProto, all *StructList) (*MethodProtoOpts, error)
type PersistOpts ¶
func ParseCommandLine ¶
func ParseCommandLine(str string) PersistOpts
type QueryProtoOpts ¶
type QueryProtoOpts struct {
// contains filtered or unexported fields
}
func NewQueryProtoOpts ¶
func NewQueryProtoOpts(qopt *persist.QLImpl, all *StructList) (*QueryProtoOpts, error)
type Service ¶
type Service struct { Desc *desc.ServiceDescriptorProto Package string // protobuf package File *FileStruct AllStructs *StructList }
func (*Service) GetQueriesOption ¶
func (*Service) GetServiceType ¶
func (s *Service) GetServiceType() *persist.PersistenceOptions
func (*Service) GetTypeMapping ¶
func (s *Service) GetTypeMapping() *persist.TypeMapping
func (*Service) GetUndoctoredQueryByName ¶
type Services ¶
type Services []*Service
func (*Services) AddService ¶
func (s *Services) AddService(pkg string, desc *desc.ServiceDescriptorProto, allStructs *StructList, file *FileStruct) *Service
func (Services) HasPersistService ¶
we are a persist service if we have persist options. meaning we are either spanner or sql
type Struct ¶
type Struct struct { Descriptor GenericDescriptor Package string ParentDescriptor *Struct IsMessage bool IsInnerType bool File *FileStruct // for determine go import path and go package EnumDesc *desc.EnumDescriptorProto MsgDesc *desc.DescriptorProto ProtoName string GoName string // contains filtered or unexported fields }
func (*Struct) GetFieldDescriptorsIfMessage ¶
func (s *Struct) GetFieldDescriptorsIfMessage() ([]*desc.FieldDescriptorProto, bool)
GetFieldDescriptors returns a slice of FieldDescriptors that exist on this message. If this is not a message, it returns empty slice, false
func (*Struct) GetFieldType ¶
func (s *Struct) GetFieldType(field string) *desc.FieldDescriptorProto
func (*Struct) GetImportedFiles ¶
func (*Struct) GetProtoName ¶
type StructList ¶
type StructList []*Struct
func NewStructList ¶
func NewStructList() *StructList
func (*StructList) AddEnum ¶
func (s *StructList) AddEnum(enum *desc.EnumDescriptorProto, parent *Struct, pkg string, file *FileStruct) *Struct
func (*StructList) AddMessage ¶
func (s *StructList) AddMessage(message *desc.DescriptorProto, parent *Struct, pkg string, file *FileStruct) *Struct
func (*StructList) Append ¶
func (s *StructList) Append(struc *Struct)
func (*StructList) GetStructByFieldDesc ¶
func (s *StructList) GetStructByFieldDesc(fld *desc.FieldDescriptorProto) *Struct
func (*StructList) GetStructByName ¶
func (s *StructList) GetStructByName(name string) *Struct
func (*StructList) GetStructByProtoName ¶
func (s *StructList) GetStructByProtoName(name string) *Struct
type TmAsField ¶
type TmAsField struct {
// contains filtered or unexported fields
}
TmAsField (TypeMappingAsField) Implements GetLabel and GetType, returning results from their GetProto equivalents
func (TmAsField) GetLabel ¶
func (t TmAsField) GetLabel() descriptor.FieldDescriptorProto_Label
func (TmAsField) GetType ¶
func (t TmAsField) GetType() descriptor.FieldDescriptorProto_Type
func (TmAsField) GetTypeName ¶
type TypeMappingProtoOpts ¶
type TypeMappingProtoOpts struct {
// contains filtered or unexported fields
}
const (
// 0 is reserved for errors. // Order is weird for historical reasons. FieldDescriptorProto_TYPE_DOUBLE FieldDescriptorProto_Type = 1 FieldDescriptorProto_TYPE_FLOAT FieldDescriptorProto_Type = 2 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if // negative values are likely. FieldDescriptorProto_TYPE_INT64 FieldDescriptorProto_Type = 3 FieldDescriptorProto_TYPE_UINT64 FieldDescriptorProto_Type = 4 // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if // negative values are likely. FieldDescriptorProto_TYPE_INT32 FieldDescriptorProto_Type = 5 FieldDescriptorProto_TYPE_FIXED64 FieldDescriptorProto_Type = 6 FieldDescriptorProto_TYPE_FIXED32 FieldDescriptorProto_Type = 7 FieldDescriptorProto_TYPE_BOOL FieldDescriptorProto_Type = 8 FieldDescriptorProto_TYPE_STRING FieldDescriptorProto_Type = 9 // Tag-delimited aggregate. // Group type is deprecated and not supported in proto3. However, Proto3 // implementations should still be able to parse the group wire format and // treat group fields as unknown fields. FieldDescriptorProto_TYPE_GROUP FieldDescriptorProto_Type = 10 FieldDescriptorProto_TYPE_MESSAGE FieldDescriptorProto_Type = 11 // New in version 2. FieldDescriptorProto_TYPE_BYTES FieldDescriptorProto_Type = 12 FieldDescriptorProto_TYPE_UINT32 FieldDescriptorProto_Type = 13 FieldDescriptorProto_TYPE_ENUM FieldDescriptorProto_Type = 14 FieldDescriptorProto_TYPE_SFIXED32 FieldDescriptorProto_Type = 15 FieldDescriptorProto_TYPE_SFIXED64 FieldDescriptorProto_Type = 16 FieldDescriptorProto_TYPE_SINT32 FieldDescriptorProto_Type = 17 FieldDescriptorProto_TYPE_SINT64 FieldDescriptorProto_Type = 18
)
optional google.protobuf.FieldDescriptorProto.Type proto_type= 2; // if proto_label is not setup we consider any option except LABAEL_REPEATED optional google.protobuf.FieldDescriptorProto.Label proto_label = 3; } repeated TypeDescriptor types = 1; }
func NewTypeMappingProtoOpts ¶
func NewTypeMappingProtoOpts(opt *persist.TypeMapping_TypeDescriptor, all *StructList) (*TypeMappingProtoOpts, error)