Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatCode

func FormatCode(filename string, buffer []byte) []byte

func GetFieldMappedProtoOption

func GetFieldMappedProtoOption(field *desc.FieldDescriptorProto) bool

    returns if this field was marked as always needing a type mapping

    func GetGoPackage

    func GetGoPackage(url string) string

      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

      func GetGoPath(url string) string

        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 OneOrZero

        func OneOrZero(hp handlerParams) string

        func P

        func P(args ...string) string

        func WriteClientStreaming

        func WriteClientStreaming(printer *Printer, params *handlerParams, isSql bool) error

        func WriteHandlers

        func WriteHandlers(p *Printer, s *Service) (outErr error)

        func WriteHooks

        func WriteHooks(p *Printer, s *Service) error

        func WriteImports

        func WriteImports(p *Printer, f *FileStruct) error

          BUG:: ONLY WORKS WITH sql.DB, needs to work with spanner

          func WriteIters

          func WriteIters(p *Printer, s *Service) (outErr error)

          func WritePackageLevelDeclarations

          func WritePackageLevelDeclarations(p *Printer, files *FileList) error

          func WritePersistServerStruct

          func WritePersistServerStruct(printer *Printer, service, db string) error

          func WriteQueries

          func WriteQueries(p *Printer, s *Service) error

          func WriteRows

          func WriteRows(p *Printer, s *Service) (outErr error)

          func WriteServerStream

          func WriteServerStream(printer *Printer, params *handlerParams, isSql bool) error

          func WriteTypeMappings

          func WriteTypeMappings(p *Printer, s *Service) error

          func WriteUnary

          func WriteUnary(printer *Printer, params *handlerParams, isSql bool) error

          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

          func (*FileList) Process

          func (fl *FileList) Process() error

          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 (g *Generator) CommandLineParameters(parameter string) error

              func (*Generator) GetResponse

              func (g *Generator) GetResponse() (*plugin_go.CodeGeneratorResponse, error)

              func (*Generator) Process

              func (g *Generator) Process() 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 Import

              type Import struct {
              	GoPackageName string
              	GoImportPath  string
              }

              type Imports

              type Imports []*Import

              func EmptyImportList

              func EmptyImportList() *Imports

              func (*Imports) Exist

              func (il *Imports) Exist(pkg string) bool

              func (*Imports) GetGoNameByStruct

              func (il *Imports) GetGoNameByStruct(str *Struct) *Import

              func (*Imports) GetImportPkgForPath

              func (il *Imports) GetImportPkgForPath(path string) string

              func (*Imports) GetOrAddImport

              func (il *Imports) GetOrAddImport(goPkg, goPath string) string

              func (Imports) String

              func (il Imports) String() string

              type Match

              type Match struct {
              	// contains filtered or unexported fields
              }

              func Matcher

              func Matcher(s *Service) Match

              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) Err

              func (m *Match) Err() error

              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) MatchQueryInField

              func (Match) MatchQueryName

              func (Match) MatchQueryName(opt *QueryProtoOpts) func(*MethodProtoOpts) bool

              func (Match) MatchQueryOutField

              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

              type PersistOpts struct {
              	Raw            map[string]string
              	PersistLibRoot string
              }

              func ParseCommandLine

              func ParseCommandLine(str string) PersistOpts

              type Printer

              type Printer struct {
              	// contains filtered or unexported fields
              }

              func (*Printer) P

              func (p *Printer) P(formatString string, args ...interface{})

              func (*Printer) PA

              func (p *Printer) PA(formatStrings []string, args ...interface{})

              func (*Printer) PTemplate

              func (p *Printer) PTemplate(t string, dot interface{})

              func (*Printer) Q

              func (p *Printer) Q(args ...string)

              func (*Printer) String

              func (p *Printer) String() string

              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) GetName

              func (s *Service) GetName() string

              func (*Service) GetQueriesOption

              func (s *Service) GetQueriesOption() *persist.QueryOpts

              func (*Service) GetServiceType

              func (s *Service) GetServiceType() *persist.PersistenceOptions

              func (*Service) GetTypeMapping

              func (s *Service) GetTypeMapping() *persist.TypeMapping

              func (*Service) GetUndoctoredQueryByName

              func (s *Service) GetUndoctoredQueryByName(queryName string) (*persist.QLImpl, error)

              func (*Service) IsSQL

              func (s *Service) IsSQL() bool

              func (*Service) IsSpanner

              func (s *Service) IsSpanner() bool

              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

              func (s Services) HasPersistService() bool

                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) GetGoName

                  func (s *Struct) GetGoName() string

                  func (*Struct) GetGoPath

                  func (s *Struct) GetGoPath() string

                  func (*Struct) GetImportedFiles

                  func (s *Struct) GetImportedFiles() *FileList

                  func (*Struct) GetProtoName

                  func (s *Struct) GetProtoName() string

                  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 (TmAsField) GetType

                    func (TmAsField) GetTypeName

                    func (t TmAsField) GetTypeName() string

                    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;
                      

                      }