Documentation ¶
Overview ¶
Package golang is the generator backend for golang.
Index ¶
- Constants
- func BackQuoted(s string) string
- func BuildRefScope(cu *CodeUtils, ast *parser.Thrift) (*Scope, *Scope, error)
- func GetImportPackage(path string) string
- func GetImportPath(cu *CodeUtils, ast *parser.Thrift) string
- func GetTypeID(t *parser.Type) string
- func GetTypeIDConstant(t *parser.Type) string
- func IsBaseType(t *parser.Type) bool
- func IsConstantInGo(v *parser.Constant) bool
- func IsFixedLengthType(t *parser.Type) bool
- func IsIntType(t *parser.Type) bool
- func IsStrType(t *parser.Type) bool
- func JoinPath(elem ...string) string
- func NeedRedirect(f *parser.Field) bool
- func SupportIsSet(f *parser.Field) bool
- func ToRefFilename(keepName bool, filename string) string
- func ToReflectionFilename(filename string) string
- func ToReflectionRefFilename(keepName bool, filename string) string
- func ZeroWriter(t *parser.Type, oprot string, err string) string
- type Code
- type CodeUtils
- func (cu *CodeUtils) BuildFuncMap() template.FuncMap
- func (cu *CodeUtils) CombineOutputPath(outputPath string, t *parser.Thrift) string
- func (cu *CodeUtils) Debug(vs ...interface{}) string
- func (cu *CodeUtils) Features() Features
- func (cu *CodeUtils) GenFieldTags(f *Field, insertPoint string) (string, error)
- func (cu *CodeUtils) GenTags(f *parser.Field, insertPoint string) (string, error)
- func (cu *CodeUtils) GetFilePath(t *parser.Thrift) string
- func (cu *CodeUtils) GetFilename(t *parser.Thrift) string
- func (cu *CodeUtils) GetKeyType(s *Scope, t *parser.Type) (*Scope, *parser.Type, error)
- func (cu *CodeUtils) GetPackageName(ast *parser.Thrift) string
- func (cu *CodeUtils) GetPackagePrefix() (pp string)
- func (cu *CodeUtils) GetValType(s *Scope, t *parser.Type) (*Scope, *parser.Type, error)
- func (cu *CodeUtils) HandleOptions(args []string) error
- func (cu *CodeUtils) Identify(name string) (s string, err error)
- func (cu *CodeUtils) Import(t *parser.Thrift) (pkg, pth string)
- func (cu *CodeUtils) MkRWCtx(root *Scope, f *Field) (*ReadWriteContext, error)
- func (cu *CodeUtils) NamespaceToFullImportPath(ns string) string
- func (cu *CodeUtils) NamespaceToImportPath(ns string) string
- func (cu *CodeUtils) NamespaceToPackage(ns string) string
- func (cu *CodeUtils) NamingStyle() styles.Naming
- func (cu *CodeUtils) ParseNamespace(ast *parser.Thrift) (ref, pkg, pth string)
- func (cu *CodeUtils) RootScope() *Scope
- func (cu *CodeUtils) SetFeatures(fs Features)
- func (cu *CodeUtils) SetNamingStyle(style styles.Naming)
- func (cu *CodeUtils) SetPackagePrefix(pp string)
- func (cu *CodeUtils) SetRootScope(s *Scope)
- func (cu *CodeUtils) SetWithFieldMask(enable bool) bool
- func (cu *CodeUtils) Template() string
- func (cu *CodeUtils) UseInitialisms(enable bool)
- func (cu *CodeUtils) UsePackage(path, repl string)
- func (cu *CodeUtils) UseTemplate(value string) error
- type Constant
- type Constants
- type Enum
- type EnumValue
- type Features
- type Field
- func (f *Field) DeepEqual() Name
- func (f *Field) DefaultTypeName() TypeName
- func (f *Field) DefaultValue() Code
- func (f *Field) Getter() Name
- func (f *Field) GoName() Name
- func (f *Field) GoTypeName() TypeName
- func (f *Field) IsNested() bool
- func (f *Field) IsResponseFieldOfResult() bool
- func (f *Field) IsSetter() Name
- func (f *Field) Reader() Name
- func (f *Field) Setter() Name
- func (f *Field) Writer() Name
- type FrugalResolver
- type Function
- func (f *Function) ArgType() *StructLike
- func (f *Function) Arguments() []*Field
- func (f *Function) GoName() Name
- func (f *Function) ResType() *StructLike
- func (f *Function) ResponseGoTypeName() TypeName
- func (f *Function) Service() *Service
- func (f *Function) Streaming() *streaming.Streaming
- func (f *Function) Throws() []*Field
- type GoBackend
- func (g *GoBackend) BuiltinPlugins() []*plugin.Desc
- func (g *GoBackend) Generate(req *plugin.Request, log backend.LogFunc) *plugin.Response
- func (g *GoBackend) GetPlugin(desc *plugin.Desc) plugin.Plugin
- func (g *GoBackend) Lang() string
- func (g *GoBackend) Name() string
- func (g *GoBackend) Options() (opts []plugin.Option)
- func (g *GoBackend) PostProcess(path string, content []byte) ([]byte, error)
- type Include
- type Includes
- type Name
- type ReadWriteContext
- func (c *ReadWriteContext) GenID(prefix string) (name string)
- func (c *ReadWriteContext) NeedFieldMask() bool
- func (c *ReadWriteContext) WithDecl() *ReadWriteContext
- func (c *ReadWriteContext) WithFieldMask(fm string) *ReadWriteContext
- func (c *ReadWriteContext) WithSource(s string) *ReadWriteContext
- func (c *ReadWriteContext) WithTarget(t string) *ReadWriteContext
- type Resolver
- func (r *Resolver) GetConstInit(name string, t *parser.Type, v *parser.ConstValue) (Code, error)
- func (r *Resolver) GetDefaultValueTypeName(f *parser.Field) (TypeName, error)
- func (r *Resolver) GetFieldInit(f *parser.Field) (Code, error)
- func (r *Resolver) GetTypeName(g *Scope, t *parser.Type) (name TypeName, err error)
- func (r *Resolver) ResolveConst(g *Scope, name string, t *parser.Type, v *parser.ConstValue) (Code, error)
- func (r *Resolver) ResolveFieldTypeName(f *parser.Field) (TypeName, error)
- func (r *Resolver) ResolveTypeName(t *parser.Type) (TypeName, error)
- type Scope
- func (s *Scope) AST() *parser.Thrift
- func (s *Scope) Constant(name string) *Constant
- func (s *Scope) Constants() Constants
- func (s *Scope) Enum(name string) *Enum
- func (s *Scope) Enums() []*Enum
- func (s *Scope) Exception(name string) *StructLike
- func (s *Scope) Exceptions() []*StructLike
- func (s *Scope) FilePackage() string
- func (s *Scope) GetFirstDescriptor() string
- func (s *Scope) GetOption(filepath string) []string
- func (s *Scope) IDLName() string
- func (s *Scope) Includes() Includes
- func (s *Scope) IsEmpty() bool
- func (s *Scope) MarshalDescriptor() string
- func (s *Scope) Namespace() namespace.Namespace
- func (s *Scope) RefPackage() string
- func (s *Scope) RefPath() string
- func (s *Scope) ResolveImports() (map[string]string, error)
- func (s *Scope) Service(name string) *Service
- func (s *Scope) Services() []*Service
- func (s *Scope) Struct(name string) *StructLike
- func (s *Scope) StructLike(name string) *StructLike
- func (s *Scope) StructLikes() (ss []*StructLike)
- func (s *Scope) Structs() []*StructLike
- func (s *Scope) Typedef(alias string) *Typedef
- func (s *Scope) Typedefs() []*Typedef
- func (s *Scope) Union(name string) *StructLike
- func (s *Scope) Unions() []*StructLike
- type Service
- type StructLike
- type TypeName
- type Typedef
Constants ¶
const ( DefaultThriftLib = "github.com/apache/thrift/lib/go/thrift" DefaultUnknownLib = "github.com/cloudwegox/thriftgo/generator/golang/extension/unknown" DefaultMetaLib = "github.com/cloudwegox/thriftgo/generator/golang/extension/meta" ThriftReflectionLib = "github.com/cloudwegox/thriftgo/thrift_reflection" ThriftFieldMaskLib = "github.com/cloudwegox/thriftgo/fieldmask" ThriftOptionLib = "github.com/cloudwegox/thriftgo/extension/thrift_option" ThriftJSONUtilLib = "github.com/cloudwegox/thriftgo/utils/json_utils" KitexStreamingLib = "github.com/cloudwego/kitex/pkg/streaming" )
Default libraries.
Variables ¶
This section is empty.
Functions ¶
func BackQuoted ¶
func GetImportPackage ¶
func GetTypeID ¶
GetTypeID returns the thrift type ID literal for the given type which is suitable to concate with "Read" or "Write" to produce a valid method name in the TProtocol interface. Note that enum types results in I32.
func GetTypeIDConstant ¶
GetTypeIDConstant returns the thrift type ID literal for the given type which is suitable to concate with "thrift." to produce a valid type ID constant.
func IsBaseType ¶
IsBaseType determines whether the given type is a base type.
func IsConstantInGo ¶
IsConstantInGo tells whether a constant in thrift IDL results in a constant in go.
func IsFixedLengthType ¶
IsFixedLengthType determines whether the given type is a fixed length type.
func NeedRedirect ¶
NeedRedirect deterimines whether the given field should result in a pointer type. Condition: struct-like || (optional non-binary base type without default vlaue).
func SupportIsSet ¶
SupportIsSet determines whether a field supports IsSet query.
func ToRefFilename ¶
func ToReflectionFilename ¶
func ToReflectionRefFilename ¶
Types ¶
type CodeUtils ¶
CodeUtils contains a set of utility functions.
func NewCodeUtils ¶
NewCodeUtils creates a new CodeUtils.
func (*CodeUtils) BuildFuncMap ¶
BuildFuncMap builds a function map for templates.
func (*CodeUtils) CombineOutputPath ¶
CombineOutputPath read the output and path variables and render them into the final path
func (*CodeUtils) GenFieldTags ¶
GenFieldTags generates go tags for the given parser.Field.
func (*CodeUtils) GetFilePath ¶
GetFilePath returns a path to the generated file for the given IDL. Note that the result is a path relative to the root output path.
func (*CodeUtils) GetKeyType ¶
GetKeyType returns the key type of the given type. T must be a map type.
func (*CodeUtils) GetPackageName ¶
GetPackageName returns a go package name for the given thrift AST.
func (*CodeUtils) GetPackagePrefix ¶
GetPackagePrefix sets the package prefix in generated codes.
func (*CodeUtils) GetValType ¶
GetValType returns the value type of the given type. T must be a container type.
func (*CodeUtils) HandleOptions ¶
HandleOptions updates the CodeUtils with options.
func (*CodeUtils) Identify ¶
Identify converts an raw name from IDL into an exported identifier in go.
func (*CodeUtils) Import ¶
Import returns the package name and the full import path for the given AST.
func (*CodeUtils) MkRWCtx ¶
func (cu *CodeUtils) MkRWCtx(root *Scope, f *Field) (*ReadWriteContext, error)
MkRWCtx = MakeReadWriteContext. Check the documents of ReadWriteContext for more informations.
func (*CodeUtils) NamespaceToFullImportPath ¶
NamespaceToFullImportPath returns an import path for the given namespace. The result path will contain the package prefix if it is set.
func (*CodeUtils) NamespaceToImportPath ¶
NamespaceToImportPath returns an import path for the given namespace. Note that the result will not have the package prefix set with SetPackagePrefix.
func (*CodeUtils) NamespaceToPackage ¶
NamespaceToPackage converts a namespace to a package.
func (*CodeUtils) NamingStyle ¶
NamingStyle returns the current naming style.
func (*CodeUtils) ParseNamespace ¶
ParseNamespace retrieves informations from the given AST and returns a reference name in the IDL, a package name for generated codes and an import path.
func (*CodeUtils) SetFeatures ¶
SetFeatures sets the feature set.
func (*CodeUtils) SetNamingStyle ¶
SetNamingStyle sets the naming style.
func (*CodeUtils) SetPackagePrefix ¶
SetPackagePrefix sets the package prefix in generated codes.
func (*CodeUtils) SetRootScope ¶
SetRootScope sets the root scope for rendering templates.
func (*CodeUtils) SetWithFieldMask ¶
func (*CodeUtils) UseInitialisms ¶
UseInitialisms sets the naming style's initialisms option.
func (*CodeUtils) UsePackage ¶
UsePackage forces the generated codes to use the specific package.
func (*CodeUtils) UseTemplate ¶
UseTemplate specifies a different template to generate codes.
type Constant ¶
Constant is a wrapper for the parser.Constant.
func (*Constant) GoTypeName ¶
GoTypeName returns the type name in go code of the constant.
func (*Constant) Initialization ¶
Initialization returns the initialization code of the constant.
type Constants ¶
type Constants []*Constant
Constants is a list of constants.
func (Constants) GoConstants ¶
GoConstants returns the subset of the current constants that each one of them results a constant in Go.
func (Constants) GoVariables ¶
GoVariables returns the subset of the current constants that each one of them results a variable in Go.
type Enum ¶
Enum is a wrapper for the parser.Enum.
type EnumValue ¶
EnumValue is a wrapper for the parser.EnumValue.
type Features ¶
type Features struct { MarshalEnumToText bool `json_enum_as_text:"Generate MarshalText and UnmarshalText for enum values"` MarshalEnum bool `enum_marshal:"Generate MarshalText for enum values"` UnmarshalEnum bool `enum_unmarshal:"Generate UnmarshalText for enum values"` GenerateSetter bool `gen_setter:"Generate Set* methods for fields"` GenDatabaseTag bool `gen_db_tag:"Generate 'db:$field' tag"` GenOmitEmptyTag bool `omitempty_for_optional:"Generate 'omitempty' tags for optional fields."` TypedefAsTypeAlias bool `use_type_alias:"Generate type alias for typedef instead of type define."` ValidateSet bool `validate_set:"Generate codes to validate the uniqueness of set elements."` ValueTypeForSIC bool `value_type_in_container:"Generate value type for struct-like in container instead of pointer type."` ScanValueForEnum bool `scan_value_for_enum:"Generate Scan and Value methods for enums to implement interfaces in std sql library."` ReorderFields bool `reorder_fields:"Reorder fields of structs to improve memory usage."` TypedEnumString bool `typed_enum_string:"Add type prefix to the string representation of enum values."` KeepUnknownFields bool `keep_unknown_fields:"Generate codes to store unrecognized fields in structs."` GenDeepEqual bool `gen_deep_equal:"Generate DeepEqual function for struct/union/exception."` CompatibleNames bool `compatible_names:"Add a '_' suffix if an name has a prefix 'New' or suffix 'Args' or 'Result'."` ReserveComments bool `reserve_comments:"Reserve comments of definitions in thrift file"` NilSafe bool `nil_safe:"Generate nil-safe getters."` FrugalTag bool `frugal_tag:"Generate 'frugal' tags."` EscapeDoubleInTag bool `unescape_double_quote:"Unescape the double quotes in literals when generating go tags."` GenerateTypeMeta bool `gen_type_meta:"Generate and register type meta for structures."` GenerateJSONTag bool `gen_json_tag:"Generate struct with 'json' tag"` AlwaysGenerateJSONTag bool `always_gen_json_tag:"Always generate 'json' tag even if go.tag is provided (Disabled by default)"` SnakeTyleJSONTag bool `snake_style_json_tag:"Generate snake style json tag"` LowerCamelCaseJSONTag bool `lower_camel_style_json_tag:"Generate lower camel case style json tag"` WithReflection bool `with_reflection:"Generate reflection info"` EnumAsINT32 bool `enum_as_int_32:"Generate enum type as int32"` CodeRefSlim bool `code_ref_slim:"Generate code ref by given idl-ref.yaml with less refs to avoid conflict"` CodeRef bool `code_ref:"Generate code ref by given idl-ref.yaml"` ExpCodeRef bool `` /* 146-byte string literal not displayed */ KeepCodeRefName bool `keep_code_ref_name:"Generate code ref but still keep file name."` TrimIDL bool `trim_idl:"Simplify IDL to the most concise form before generating code."` EnableNestedStruct bool `` /* 147-byte string literal not displayed */ JSONStringer bool `json_stringer:"Generate the JSON marshal method in String() method."` WithFieldMask bool `with_field_mask:"Support field-mask for generated code."` FieldMaskHalfway bool `field_mask_halfway:"Support set field-mask on not-root struct."` FieldMaskZeroRequired bool `field_mask_zero_required:"Write zero value instead of current value for required fields filtered by fieldmask."` ThriftStreaming bool `thrift_streaming:"Recognize thrift streaming annotation and generate streaming code."` NoDefaultSerdes bool `no_default_serdes:"Do not generate default thrift serdes code."` NoAliasTypeReflectionMethod bool `` /* 153-byte string literal not displayed */ EnableRefInterface bool `` /* 151-byte string literal not displayed */ UseOption bool `` /* 127-byte string literal not displayed */ // ForceUseOption bool `use_option:"Forcefully parse all Thrift annotations into struct-style option fields. If parsing is not possible, an error will be thrown."` NoFmt bool `` /* 129-byte string literal not displayed */ SkipEmpty bool `skip_empty:"If there's not content in file, just skip it. Later this feature will be a default feature."` NoProcessor bool `no_processor:" Do not generate default thrift processor and client. Later this feature will be a default feature."` GetEnumAnnotation bool `get_enum_annotation:"Generate GetAnnotation method for enum types."` }
Features controls the behavior of CodeUtils.
type Field ¶
Field is a wrapper for the parser.Field.
func (*Field) DefaultTypeName ¶
DefaultTypeName returns the type name in go code of the default value of the field. Note that it might be different with the result of GoTypeName.
func (*Field) DefaultValue ¶
DefaultValue returns the go code of the field for its Initialization. Note that the code exists only when the field has default value.
func (*Field) GoTypeName ¶
GoTypeName returns the type name in go code of the field.
func (*Field) IsResponseFieldOfResult ¶
IsResponseFieldOfResult tells if the field is the response of a result type of a method.
type FrugalResolver ¶
type FrugalResolver struct {
// contains filtered or unexported fields
}
FrugalResolver resolves type names for frugal.
func NewFrugalResolver ¶
func NewFrugalResolver(root *Scope, cu *CodeUtils) *FrugalResolver
NewFrugalResolver creates a new FrugalResolver with the given scope.
func (*FrugalResolver) ResolveFrugalTypeName ¶
func (r *FrugalResolver) ResolveFrugalTypeName(t *parser.Type) (TypeName, error)
ResolveFrugalTypeName returns a legal type name in frugal for the given AST type.
type Function ¶
Function is a wrapper for the parser.Function.
func (*Function) ArgType ¶
func (f *Function) ArgType() *StructLike
ArgType returns the synthesized structure that wraps of the function.
func (*Function) ResType ¶
func (f *Function) ResType() *StructLike
ResType returns the synthesized structure of arguments of the function.
func (*Function) ResponseGoTypeName ¶
ResponseGoTypeName returns the go type of the response type of the function.
type GoBackend ¶
type GoBackend struct {
// contains filtered or unexported fields
}
GoBackend generates go codes. The zero value of GoBackend is ready for use.
func (*GoBackend) BuiltinPlugins ¶
BuiltinPlugins implements the Backend interface.
type Include ¶
Include associates an import in golang with the corresponding scope that built from an thrift AST in the include list.
type Includes ¶
type Includes []*Include
Includes is a list of Include objects.
func (Includes) ByAST ¶
ByAST returns an Include whose scope matches the given AST. It returns nil if such an Include is not found.
type Name ¶
type Name string
Name is the type of identifiers converted from a thrift AST to Go code.
type ReadWriteContext ¶
type ReadWriteContext struct { Type *parser.Type TypeName TypeName // The type name in Go code TypeID string // For `thrift.TProtocol.(Read|Write)${TypeID}` methods IsPointer bool // Whether the target type is a pointer type in Go KeyCtx *ReadWriteContext // sub-context if the type is map ValCtx *ReadWriteContext // sub-context if the type is container Target string // The target for assignment Source string // The variable for right hand operand in deep-equal NeedDecl bool // Whether a declaration of target is needed FieldMask string // contains filtered or unexported fields }
ReadWriteContext contains information for generating codes in ReadField* and WriteField* functions. Each context stands for a struct field, a map key, a map value, a list elemement, or a set elemement.
func (*ReadWriteContext) GenID ¶
func (c *ReadWriteContext) GenID(prefix string) (name string)
GenID returns a local variable with the given name as prefix.
func (*ReadWriteContext) NeedFieldMask ¶
func (c *ReadWriteContext) NeedFieldMask() bool
func (*ReadWriteContext) WithDecl ¶
func (c *ReadWriteContext) WithDecl() *ReadWriteContext
WithDecl claims that the context needs a variable declaration.
func (*ReadWriteContext) WithFieldMask ¶
func (c *ReadWriteContext) WithFieldMask(fm string) *ReadWriteContext
WithDecl claims that the context needs a variable declaration.
func (*ReadWriteContext) WithSource ¶
func (c *ReadWriteContext) WithSource(s string) *ReadWriteContext
WithSource sets the source name.
func (*ReadWriteContext) WithTarget ¶
func (c *ReadWriteContext) WithTarget(t string) *ReadWriteContext
WithTarget sets the target name.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves names for types, names and initialization value for thrift AST nodes in a scope (the root scope).
func NewResolver ¶
NewResolver creates a new Resolver with the given scope.
func (*Resolver) GetConstInit ¶
GetConstInit returns the initialization code for a constant.
func (*Resolver) GetDefaultValueTypeName ¶
GetDefaultValueTypeName returns a type name suitable for the default value of the given field.
func (*Resolver) GetFieldInit ¶
GetFieldInit returns the initialization code for a field. The given field must have a default value.
func (*Resolver) GetTypeName ¶
GetTypeName returns a an type name (with selector if necessary) of the given type to be used in the root file. The type t must be a parser.Type associated with g.
func (*Resolver) ResolveConst ¶
func (r *Resolver) ResolveConst(g *Scope, name string, t *parser.Type, v *parser.ConstValue) (Code, error)
ResolveConst returns the initialization code for a constant or a default value. The type t must be a parser.Type associated with g.
func (*Resolver) ResolveFieldTypeName ¶
ResolveFieldTypeName returns a legal type name in go for the given field.
type Scope ¶
type Scope struct {
// contains filtered or unexported fields
}
Scope contains the type symbols defined in a thrift IDL and wraps them to provide access to resolved names in go code.
func BuildScope ¶
BuildScope creates a scope of the AST with its includes processed recursively. todo check cache
func (*Scope) Constant ¶
Constant returns a constant defined in the current scope with the given name. It returns nil if the constant is not found.
func (*Scope) Enum ¶
Enum returns an enum defined in the current scope with the given name. It returns nil if the enum is not found.
func (*Scope) Exception ¶
func (s *Scope) Exception(name string) *StructLike
Exception returns an exception defined in the current scope with the given name. It returns nil if the exception is not found.
func (*Scope) Exceptions ¶
func (s *Scope) Exceptions() []*StructLike
Exceptions returns all exception defined in the current scope.
func (*Scope) FilePackage ¶
func (*Scope) GetFirstDescriptor ¶
func (*Scope) MarshalDescriptor ¶
func (*Scope) RefPackage ¶
func (*Scope) ResolveImports ¶
ResolveImports returns a map of import path to alias built from the include list of the IDL. An alias may be an empty string to indicate no alias is need for the import path.
func (*Scope) Service ¶
Service returns a service defined in the current scope with the given name. It returns nil if the service is not found.
func (*Scope) Struct ¶
func (s *Scope) Struct(name string) *StructLike
Struct returns a struct defined in the current scope with the given name. It returns nil if the struct is not found.
func (*Scope) StructLike ¶
func (s *Scope) StructLike(name string) *StructLike
StructLike returns a struct-like defined in the current scope with the given name. It returns nil if the struct-like is not found.
func (*Scope) StructLikes ¶
func (s *Scope) StructLikes() (ss []*StructLike)
StructLikes returns all struct-like defined in the current scope.
func (*Scope) Structs ¶
func (s *Scope) Structs() []*StructLike
Structs returns all struct defined in the current scope.
func (*Scope) Typedef ¶
Typedef returns a typedef defined in the current scope with the given name. It returns nil if the typedef is not found.
func (*Scope) Union ¶
func (s *Scope) Union(name string) *StructLike
Union returns a union defined in the current scope with the given name. It returns nil if the union is not found.
func (*Scope) Unions ¶
func (s *Scope) Unions() []*StructLike
Unions returns all union defined in the current scope.
type Service ¶
Service is a wrapper for the parser.Service.
func (*Service) Base ¶
Base returns the base service that the current service extends. It returns nil if the service has no base service.
func (*Service) Function ¶
Function returns a function defined in the service with the given name. It returns nil if the function is not found.
type StructLike ¶
type StructLike struct { *parser.StructLike // contains filtered or unexported fields }
StructLike is a wrapper for the parser.StructLike.
func (*StructLike) Field ¶
func (s *StructLike) Field(name string) *Field
Field returns a field of the struct-like that has the given name. It returns nil if such a field is not found.
func (*StructLike) Fields ¶
func (s *StructLike) Fields() []*Field
Fields returns all fields defined in the struct-like.
func (*StructLike) GoName ¶
func (s *StructLike) GoName() Name
GoName returns the name in go code of the struct-like.
func (*StructLike) IsAlias ¶
func (s *StructLike) IsAlias() bool
IsAlias returns whether this type is alias of existing type
func (*StructLike) Namespace ¶
func (s *StructLike) Namespace() namespace.Namespace
Namespace returns the namescope of the struct-like.
type TypeName ¶
type TypeName string
TypeName is the type for Go symbols converted from a thrift AST. It provides serveral methods to manipulate a type name of a symbol.
func (TypeName) IsPointer ¶
IsPointer reports whether the type name is a pointer type by detecting the prefix "*".
func (TypeName) Pointerize ¶
Pointerize returns the pointer type of the current type name.