Documentation ¶
Index ¶
- Constants
- Variables
- func BaseName(name string) string
- func CamelCase(s string) string
- func ExportedIdentifier(name string) string
- func GoFileName(fileName string) string
- func Identifier(name string) string
- func SnakeCase(s string) string
- func StatusCodeVar(code int) string
- func StatusText(statusCode int) string
- func UnTitle(s string) string
- func UnexportedIdentifier(name string) string
- func UnsafePointerReference(p string) string
- func ValidateIdent(ident string) error
- func ValidateIdents(idents []string) error
- func ValidateIfOperation(op token.Token) error
- func ValidateOperation(op token.Token) error
- func ValidateParameters(parameters []*Parameter) error
- func ValueList(names []string) string
- type AnonymousFuncGenerator
- type AnonymousFuncGeneratorMetaData
- type Case
- type CaseGenerator
- type CaseGeneratorMetaData
- type ClosureGenerator
- type ClosureGeneratorMetaData
- type CommentGenerator
- type CommentMetaData
- type ConstGenerator
- type ConstMetadata
- type DefaultCase
- type DefaultCaseGenerator
- type DefaultCaseGeneratorMetaData
- type FileGenerator
- func (gen *FileGenerator) Closure(colsures ...*ClosureGenerator) error
- func (gen *FileGenerator) Const(g *ConstGenerator) error
- func (gen *FileGenerator) Func(fncs ...*FuncGenerator) error
- func (gen *FileGenerator) GetFileName() string
- func (gen *FileGenerator) HeaderComment(generator *CommentGenerator) error
- func (gen *FileGenerator) Import(alias string, Import string) error
- func (gen *FileGenerator) Interface(g *InterfaceGenerator) error
- func (gen *FileGenerator) Prototype(g *PrototypeGenerator) error
- func (gen *FileGenerator) Render() (string, error)
- func (gen *FileGenerator) RenderAndFormatCode() ([]byte, error)
- func (gen *FileGenerator) RenderBytes() ([]byte, error)
- func (gen *FileGenerator) Type(typs ...*StructGenerator) error
- func (gen *FileGenerator) TypesWithMethods(tg Type) error
- func (gen *FileGenerator) TypesWithoutGroup(typs ...*StructGenerator) error
- func (gen *FileGenerator) Var(varObject string) error
- type FuncGenerator
- type FuncGeneratorMetaData
- type Generator
- type GeneratorError
- type GeneratorErrorString
- type GoBlockGenerator
- func (gen *GoBlockGenerator) AnonymousGoFunc(generator *AnonymousFuncGenerator) error
- func (gen *GoBlockGenerator) Caller(fnc TypeReference, parameters []string) error
- func (gen *GoBlockGenerator) CloseIf()
- func (gen *GoBlockGenerator) CloseRange()
- func (gen *GoBlockGenerator) Command(cmd string, params []string)
- func (gen *GoBlockGenerator) DefAppend(vars string, params []string) error
- func (gen *GoBlockGenerator) DefAssert(vars []string, varName string, typ TypeReference) error
- func (gen *GoBlockGenerator) DefAssginCall(vars []string, fnc TypeReference, params []string) error
- func (gen *GoBlockGenerator) DefCall(vars []string, fnc TypeReference, params []string) error
- func (gen *GoBlockGenerator) DefElseIf(rightSide string, operation token.Token, leftSide string) error
- func (gen *GoBlockGenerator) DefIfBegin(rightSide string, operation token.Token, leftSide string) error
- func (gen *GoBlockGenerator) DefIfWithOwnScopeBegin(caller string, rightSide string, operation token.Token, leftSide string) error
- func (gen *GoBlockGenerator) DefLongVar(varName, varType string) error
- func (gen *GoBlockGenerator) DefMake(vars string, params []string) error
- func (gen *GoBlockGenerator) DefNew(varName string, typ TypeReference) error
- func (gen *GoBlockGenerator) DefOperation(varName string, rightSide string, operation token.Token, leftSide string) error
- func (gen *GoBlockGenerator) DefRangeBegin(index string, value string, list string) error
- func (gen *GoBlockGenerator) DefShortVar(varName, varType string) error
- func (gen *GoBlockGenerator) DefStruct(varName, typ, propertyOfTyp string) error
- func (gen *GoBlockGenerator) Defer(fnc TypeReference, parameters []string) error
- func (gen *GoBlockGenerator) Else()
- func (gen *GoBlockGenerator) InitStruct(statement string, initStructGenerator *InitStructGenerator, ...) error
- func (gen *GoBlockGenerator) Return(params ...[]string)
- func (gen *GoBlockGenerator) ReturnCaller(fnc TypeReference, parameters []string) error
- func (gen *GoBlockGenerator) SCall(fnc TypeReference, params []string) (string, error)
- func (gen *GoBlockGenerator) SCallWithDefVar(vars []string, fnc TypeReference, params []string) (string, error)
- func (gen *GoBlockGenerator) SliceLiteral(sliceGenerator SliceLiteralGenerator) error
- func (gen *GoBlockGenerator) StructAssignment(typ, propertyOfTyp string, valueToAssign string) error
- func (gen *GoBlockGenerator) TypeSwitch(switchGenerator SwitchGenerator) error
- type GoBlockMetaData
- type GoGenerator
- type Import
- type ImportDecl
- type ImportSpec
- type InitStructField
- type InitStructFieldTmplValues
- type InitStructGenerator
- type InterfaceGenerator
- type InterfaceMetadata
- type InterfacePrototypeMetadata
- type MethodGenerator
- type MethodGeneratorMetaData
- type Parameter
- type PrototypeGenerator
- type PrototypeMetadata
- type SliceLiteralGenerator
- type SliceLiteralMetadata
- type StructFieldTmplValues
- type StructGenerator
- func (gen *StructGenerator) AddExportedField(name string, typ TypeReference, comment string) error
- func (gen *StructGenerator) AddMethod(fg ...*MethodGenerator)
- func (gen *StructGenerator) AddUnexportedField(name string, typ TypeReference, comment string) error
- func (gen *StructGenerator) Composition(typ TypeReference) error
- func (gen *StructGenerator) GetMethods() []*MethodGenerator
- func (gen *StructGenerator) Render() (string, error)
- func (gen *StructGenerator) Type(typ TypeReference, comment string) error
- type StructTmplValues
- type SwitchGenerator
- type SwitchGeneratorMetaData
- type Type
- type TypeReference
Constants ¶
const ( CallerTpl string = "%s(%s)\n" DefAssginCallTpl string = "%s := %s(%s)\n" DefCallTpl string = "%s = %s(%s)\n" DefAppendTpl string = "%s = append(%s)\n" DefSCallTpl string = "%s := %s(%s)" DefVarShortTpl string = "%s := %s\n" DefVarLongTpl string = "var %s %s\n" DefNewTpl string = "%s := new(%s)\n" DefOperationTpl string = "%s := %s %s %s\n" DefAssertTpl string = "%s := %s.(%s)\n" DefStructTpl string = "%s := %s.%s\n" DefReturnTpl string = "return \n" DefReturnWithValuesTpl string = "return %s\n" CommandTpl string = "%s %s\n" StructAssignTpl string = "%s.%s = %s\n" IfStatmentTpl string = "if %s %s %s {\n" IfStatmentWithOwnScopeTpl string = "if %s; %s %s %s {\n" ElseStatmentTpl string = "} else {\n" ElseIfStatmentTpl string = "} else if %s %s %s {\n" IfEndTpl string = "}\n" RangeTpl string = "for %s,%s := range %s {\n" RangeEndTpl string = "}\n" DeferTpl string = "defer %s \n" )
const AnonymousfuncTpl string = `` /* 146-byte string literal not displayed */
const AnonymousfuncTplName = "func"
const CaseTpl string = `
case {{ .Typ }}:
{{range $i, $line := .Lines -}}
{{ $line }}
{{- end}}
`
const DefaultCaseTpl string = `
default:
{{range $i, $line := .Lines -}}
{{ $line }}
{{- end}}
`
const UnqualifiedPrefix = "_unqualified"
UnqualifiedPrefix The prefix for type aliases that will be interpreted as unqualified
Variables ¶
var ( // String A TypeReference for string String = TypeReferenceFromInstance("") // String A TypeReference for string pointer StringPointer = TypeReferenceFromInstance(stringPointerFunc()) // Bool A TypeReference for bool Bool = TypeReferenceFromInstance(false) // Bool A TypeReference for bool pointer BoolPointer = TypeReferenceFromInstance(boolPointerFunc()) // Int A TypeReference for int Int = TypeReferenceFromInstance(0) // Int A TypeReference for int IntPointer = TypeReferenceFromInstance(intPointerFunc()) // Int8 A TypeReference for int8 Int8 = TypeReferenceFromInstance(int8(0)) // Int8 A TypeReference for int8 pointer Int8Pointer = TypeReferenceFromInstance(int8PointerFunc) // Int16 A TypeReference for int16 Int16 = TypeReferenceFromInstance(int16(0)) // Int16 A TypeReference for int16 pointer Int16Pointer = TypeReferenceFromInstance(int16PointerFunc) // Int32 A TypeReference for int32 Int32 = TypeReferenceFromInstance(int32(0)) // Int32 A TypeReference for int32 pointer Int32Pointer = TypeReferenceFromInstance(int32PointerFunc) // Int64 A TypeReference for int64 Int64 = TypeReferenceFromInstance(int64(0)) // Int64 A TypeReference for int64 pointer Int64Pointer = TypeReferenceFromInstance(int64PointerFunc()) // Int A TypeReference for int Uint = TypeReferenceFromInstance(uint(0)) // Int A TypeReference for int UintPointer = TypeReferenceFromInstance(uintPointerFunc()) // Int8 A TypeReference for int8 Uint8 = TypeReferenceFromInstance(uint8(0)) // Int8 A TypeReference for int8 pointer Uint8Pointer = TypeReferenceFromInstance(uint8PointerFunc) // Int16 A TypeReference for int16 Uint16 = TypeReferenceFromInstance(uint16(0)) // Int16 A TypeReference for int16 pointer Uint16Pointer = TypeReferenceFromInstance(uint16PointerFunc) // Int32 A TypeReference for int32 Uint32 = TypeReferenceFromInstance(uint32(0)) // Int32 A TypeReference for int32 pointer Uint32Pointer = TypeReferenceFromInstance(uint32PointerFunc) // Int64 A TypeReference for int64 Uint64 = TypeReferenceFromInstance(uint64(0)) // Int64 A TypeReference for int64 pointer Uint64Pointer = TypeReferenceFromInstance(uint64PointerFunc()) // todo missing pointers // Uintptr A TypeReference for uintptr Uintptr = TypeReferenceFromInstance(uintptr(0)) // Float32 A TypeReference for float32 Float32 = TypeReferenceFromInstance(float32(0)) // Float64 A TypeReference for float64 Float64 = TypeReferenceFromInstance(float64(0)) // Complex64 A TypeReference for complex64 Complex64 = TypeReferenceFromInstance(complex64(0)) // Complex128 A TypeReference for complex128 Complex128 = TypeReferenceFromInstance(complex128(0)) // Byte A TypeReference for byte Byte = TypeReferenceFromInstanceWithCustomName(uint8(0), "byte") // Rune A TypeReference for rune Rune = TypeReferenceFromInstanceWithCustomName(int32(0), "rune") // Error A TypeReference for error Error = TypeReferenceFromInstanceWithCustomName(errors.New(""), "error") )
Functions ¶
func BaseName ¶
BaseName the last path element of a slash-delimited name, with the last dotted suffix removed.
func SnakeCase ¶
SnakeCase converts a string from CamelCase to snake_case.
func StatusCodeVar ¶
StatusCodeVar returns a var for the HTTP status code. It returns the empty string if the code is unknown.
Types ¶
type AnonymousFuncGenerator ¶
type AnonymousFuncGenerator struct { GoGenerator GoBlockGenerator TypeFuncMetadata AnonymousFuncGeneratorMetaData }
func NewAnonymousGoFunc ¶
func NewAnonymousGoFunc(varName string, parameters []*Parameter, returns []TypeReference) (*AnonymousFuncGenerator, error)
func (*AnonymousFuncGenerator) Render ¶
func (gen *AnonymousFuncGenerator) Render() (string, error)
type AnonymousFuncGeneratorMetaData ¶
type CaseGenerator ¶
type CaseGenerator struct { GoGenerator GoBlockGenerator CaseMetaData CaseGeneratorMetaData }
func NewCaseGenerator ¶
func NewCaseGenerator(value string) (*CaseGenerator, error)
func (*CaseGenerator) Render ¶
func (gen *CaseGenerator) Render() (string, error)
type ClosureGenerator ¶
type ClosureGenerator struct { GoGenerator GoBlockGenerator TypeFuncMetadata ClosureGeneratorMetaData }
func NewClosureFunc ¶
func NewClosureFunc(name string, parameters []*Parameter, f *FuncGenerator) (*ClosureGenerator, error)
func (*ClosureGenerator) Render ¶
func (gen *ClosureGenerator) Render() (string, error)
type ClosureGeneratorMetaData ¶
type CommentGenerator ¶
type CommentGenerator struct { GoGenerator CommentMetaData CommentMetaData }
func NewGoComment ¶
func NewGoComment() *CommentGenerator
func (*CommentGenerator) P ¶
func (gen *CommentGenerator) P(s string)
func (*CommentGenerator) Pf ¶
func (gen *CommentGenerator) Pf(format string, a ...interface{})
func (*CommentGenerator) Render ¶
func (gen *CommentGenerator) Render() (string, error)
type ConstGenerator ¶
type ConstGenerator struct { GoGenerator ConstMetaData ConstMetadata }
func NewGoConst ¶
func NewGoConst(name string, typeReference TypeReference, value string, commentGenerator *CommentGenerator) (*ConstGenerator, error)
func (*ConstGenerator) Render ¶
func (gen *ConstGenerator) Render() (string, error)
type ConstMetadata ¶
type DefaultCaseGenerator ¶
type DefaultCaseGenerator struct { GoGenerator GoBlockGenerator CaseMetaData DefaultCaseGeneratorMetaData }
func NewDefaultCaseGenerator ¶
func NewDefaultCaseGenerator() (*DefaultCaseGenerator, error)
func (*DefaultCaseGenerator) Render ¶
func (gen *DefaultCaseGenerator) Render() (string, error)
type FileGenerator ¶
type FileGenerator struct { GoGenerator FileMetaData fileMetadata }
func NewGoFile ¶
func NewGoFile(pkg string, fileName string) (*FileGenerator, error)
func (*FileGenerator) Closure ¶
func (gen *FileGenerator) Closure(colsures ...*ClosureGenerator) error
func (*FileGenerator) Const ¶
func (gen *FileGenerator) Const(g *ConstGenerator) error
func (*FileGenerator) Func ¶
func (gen *FileGenerator) Func(fncs ...*FuncGenerator) error
func (*FileGenerator) GetFileName ¶
func (gen *FileGenerator) GetFileName() string
func (*FileGenerator) HeaderComment ¶
func (gen *FileGenerator) HeaderComment(generator *CommentGenerator) error
func (*FileGenerator) Import ¶
func (gen *FileGenerator) Import(alias string, Import string) error
func (*FileGenerator) Interface ¶
func (gen *FileGenerator) Interface(g *InterfaceGenerator) error
func (*FileGenerator) Prototype ¶
func (gen *FileGenerator) Prototype(g *PrototypeGenerator) error
func (*FileGenerator) Render ¶
func (gen *FileGenerator) Render() (string, error)
func (*FileGenerator) RenderAndFormatCode ¶
func (gen *FileGenerator) RenderAndFormatCode() ([]byte, error)
func (*FileGenerator) RenderBytes ¶
func (gen *FileGenerator) RenderBytes() ([]byte, error)
func (*FileGenerator) Type ¶
func (gen *FileGenerator) Type(typs ...*StructGenerator) error
func (*FileGenerator) TypesWithMethods ¶
func (gen *FileGenerator) TypesWithMethods(tg Type) error
func (*FileGenerator) TypesWithoutGroup ¶
func (gen *FileGenerator) TypesWithoutGroup(typs ...*StructGenerator) error
func (*FileGenerator) Var ¶
func (gen *FileGenerator) Var(varObject string) error
type FuncGenerator ¶
type FuncGenerator struct { GoGenerator GoBlockGenerator TypeFuncMetadata FuncGeneratorMetaData }
func NewGoFunc ¶
func NewGoFunc(name string, parameters []*Parameter, returns []TypeReference, comment string) (*FuncGenerator, error)
func (*FuncGenerator) Render ¶
func (gen *FuncGenerator) Render() (string, error)
type FuncGeneratorMetaData ¶
type GeneratorError ¶
type GeneratorError struct {
// contains filtered or unexported fields
}
func NewGeneratorError ¶
func NewGeneratorError(generator interface{}, err error) *GeneratorError
func (*GeneratorError) Error ¶
func (e *GeneratorError) Error() string
type GeneratorErrorString ¶
type GeneratorErrorString struct {
// contains filtered or unexported fields
}
func NewGeneratorErrorString ¶
func NewGeneratorErrorString(generator interface{}, s string) *GeneratorErrorString
func (*GeneratorErrorString) Error ¶
func (e *GeneratorErrorString) Error() string
type GoBlockGenerator ¶
type GoBlockGenerator struct {
MetaData GoBlockMetaData
}
func (*GoBlockGenerator) AnonymousGoFunc ¶
func (gen *GoBlockGenerator) AnonymousGoFunc(generator *AnonymousFuncGenerator) error
func (*GoBlockGenerator) Caller ¶
func (gen *GoBlockGenerator) Caller(fnc TypeReference, parameters []string) error
func (*GoBlockGenerator) CloseIf ¶
func (gen *GoBlockGenerator) CloseIf()
func (*GoBlockGenerator) CloseRange ¶
func (gen *GoBlockGenerator) CloseRange()
func (*GoBlockGenerator) Command ¶
func (gen *GoBlockGenerator) Command(cmd string, params []string)
func (*GoBlockGenerator) DefAppend ¶
func (gen *GoBlockGenerator) DefAppend(vars string, params []string) error
func (*GoBlockGenerator) DefAssert ¶
func (gen *GoBlockGenerator) DefAssert(vars []string, varName string, typ TypeReference) error
func (*GoBlockGenerator) DefAssginCall ¶
func (gen *GoBlockGenerator) DefAssginCall(vars []string, fnc TypeReference, params []string) error
func (*GoBlockGenerator) DefCall ¶
func (gen *GoBlockGenerator) DefCall(vars []string, fnc TypeReference, params []string) error
func (*GoBlockGenerator) DefElseIf ¶
func (*GoBlockGenerator) DefIfBegin ¶
func (*GoBlockGenerator) DefIfWithOwnScopeBegin ¶
func (*GoBlockGenerator) DefLongVar ¶
func (gen *GoBlockGenerator) DefLongVar(varName, varType string) error
func (*GoBlockGenerator) DefMake ¶
func (gen *GoBlockGenerator) DefMake(vars string, params []string) error
func (*GoBlockGenerator) DefNew ¶
func (gen *GoBlockGenerator) DefNew(varName string, typ TypeReference) error
func (*GoBlockGenerator) DefOperation ¶
func (*GoBlockGenerator) DefRangeBegin ¶
func (gen *GoBlockGenerator) DefRangeBegin(index string, value string, list string) error
func (*GoBlockGenerator) DefShortVar ¶
func (gen *GoBlockGenerator) DefShortVar(varName, varType string) error
func (*GoBlockGenerator) DefStruct ¶
func (gen *GoBlockGenerator) DefStruct(varName, typ, propertyOfTyp string) error
func (*GoBlockGenerator) Defer ¶
func (gen *GoBlockGenerator) Defer(fnc TypeReference, parameters []string) error
func (*GoBlockGenerator) Else ¶
func (gen *GoBlockGenerator) Else()
func (*GoBlockGenerator) InitStruct ¶
func (gen *GoBlockGenerator) InitStruct(statement string, initStructGenerator *InitStructGenerator, pointerReference bool) error
func (*GoBlockGenerator) Return ¶
func (gen *GoBlockGenerator) Return(params ...[]string)
func (*GoBlockGenerator) ReturnCaller ¶
func (gen *GoBlockGenerator) ReturnCaller(fnc TypeReference, parameters []string) error
func (*GoBlockGenerator) SCall ¶
func (gen *GoBlockGenerator) SCall(fnc TypeReference, params []string) (string, error)
func (*GoBlockGenerator) SCallWithDefVar ¶
func (gen *GoBlockGenerator) SCallWithDefVar(vars []string, fnc TypeReference, params []string) (string, error)
func (*GoBlockGenerator) SliceLiteral ¶
func (gen *GoBlockGenerator) SliceLiteral(sliceGenerator SliceLiteralGenerator) error
func (*GoBlockGenerator) StructAssignment ¶
func (gen *GoBlockGenerator) StructAssignment(typ, propertyOfTyp string, valueToAssign string) error
func (*GoBlockGenerator) TypeSwitch ¶
func (gen *GoBlockGenerator) TypeSwitch(switchGenerator SwitchGenerator) error
type GoGenerator ¶
type GoGenerator struct { TplName string // contains filtered or unexported fields }
func (*GoGenerator) InitTemplate ¶
func (gen *GoGenerator) InitTemplate(tpl string)
func (*GoGenerator) OverwriteTemplate ¶
func (gen *GoGenerator) OverwriteTemplate(tpl string)
func (*GoGenerator) PrepareComment ¶
func (gen *GoGenerator) PrepareComment(comment string) []string
func (*GoGenerator) RenderBytesData ¶
func (gen *GoGenerator) RenderBytesData(metaData interface{}) ([]byte, error)
type Import ¶
type Import interface { // GetPackage returns the go import package, like reflect.Type.PkgPath() GetPackage() string // GetAlias returns an alias string to refer to the import package, or the // empty string to omit an import alias. GetAlias() string }
Import represent an individual imported package.
type ImportSpec ¶
ImportSpec implements Import to represent an imported go package
func (*ImportSpec) GetAlias ¶
func (i *ImportSpec) GetAlias() string
GetAlias returns the alias associated with the package
func (*ImportSpec) GetPackage ¶
func (i *ImportSpec) GetPackage() string
GetPackage returns the package
type InitStructFieldTmplValues ¶
type InitStructFieldTmplValues struct { Fields []*InitStructField Typ string }
type InitStructGenerator ¶
type InitStructGenerator struct { GoGenerator MetaData InitStructFieldTmplValues }
func NewInitGoStruct ¶
func NewInitGoStruct(typ string) (*InitStructGenerator, error)
func (*InitStructGenerator) AddExportedValueToField ¶
func (gen *InitStructGenerator) AddExportedValueToField(name, value string) error
func (*InitStructGenerator) AddUnexportedValueToField ¶
func (gen *InitStructGenerator) AddUnexportedValueToField(name, value string) error
func (*InitStructGenerator) Render ¶
func (gen *InitStructGenerator) Render() (string, error)
type InterfaceGenerator ¶
type InterfaceGenerator struct { GoGenerator InterfaceMetadata InterfaceMetadata }
func NewGoInterface ¶
func NewGoInterface(name string) (*InterfaceGenerator, error)
func (*InterfaceGenerator) Prototype ¶
func (gen *InterfaceGenerator) Prototype(name string, parameters []*Parameter, returns []TypeReference, comment string) error
func (*InterfaceGenerator) Render ¶
func (gen *InterfaceGenerator) Render() (string, error)
type InterfaceMetadata ¶
type InterfaceMetadata struct { Name string HeaderComment string Prototypes []InterfacePrototypeMetadata }
type InterfacePrototypeMetadata ¶
type MethodGenerator ¶
type MethodGenerator struct { GoGenerator GoBlockGenerator TypeFuncMetadata MethodGeneratorMetaData }
func NewGoMethod ¶
func NewGoMethod(TypShortcut, methodOfTyp, name string, parameters []*Parameter, returns []TypeReference, comment string) (*MethodGenerator, error)
func (*MethodGenerator) Render ¶
func (gen *MethodGenerator) Render() (string, error)
type MethodGeneratorMetaData ¶
type Parameter ¶
type Parameter struct { NameOfParameter string Typ TypeReference }
func NewParameterWithTypeReference ¶
func NewParameterWithTypeReference(name string, t TypeReference) *Parameter
func NewParameterWithTypeReferenceFromInstance ¶
type PrototypeGenerator ¶
type PrototypeGenerator struct { GoGenerator PrototypeMetadata PrototypeMetadata }
func NewGoFuncPrototype ¶
func NewGoFuncPrototype(name string, parameters []*Parameter, returns []TypeReference, comment string) (*PrototypeGenerator, error)
func (*PrototypeGenerator) Render ¶
func (gen *PrototypeGenerator) Render() (string, error)
type PrototypeMetadata ¶
type SliceLiteralGenerator ¶
type SliceLiteralGenerator struct { GoGenerator SliceMetaData SliceLiteralMetadata }
func NewGoSliceLiteral ¶
func NewGoSliceLiteral(varName string, typeReference TypeReference, len int) (*SliceLiteralGenerator, error)
func (*SliceLiteralGenerator) Append ¶
func (gen *SliceLiteralGenerator) Append(s string)
func (*SliceLiteralGenerator) Render ¶
func (gen *SliceLiteralGenerator) Render() (string, error)
type SliceLiteralMetadata ¶
type StructFieldTmplValues ¶
type StructGenerator ¶
type StructGenerator struct { GoGenerator Group bool StructMetaData StructTmplValues }
func NewGoStruct ¶
func NewGoStruct(name string, withoutGroup bool, exported bool) (*StructGenerator, error)
func (*StructGenerator) AddExportedField ¶
func (gen *StructGenerator) AddExportedField(name string, typ TypeReference, comment string) error
func (*StructGenerator) AddMethod ¶
func (gen *StructGenerator) AddMethod(fg ...*MethodGenerator)
func (*StructGenerator) AddUnexportedField ¶
func (gen *StructGenerator) AddUnexportedField(name string, typ TypeReference, comment string) error
func (*StructGenerator) Composition ¶
func (gen *StructGenerator) Composition(typ TypeReference) error
func (*StructGenerator) GetMethods ¶
func (gen *StructGenerator) GetMethods() []*MethodGenerator
func (*StructGenerator) Render ¶
func (gen *StructGenerator) Render() (string, error)
func (*StructGenerator) Type ¶
func (gen *StructGenerator) Type(typ TypeReference, comment string) error
type StructTmplValues ¶
type StructTmplValues struct { Name string Comment []string Fields []*StructFieldTmplValues Methods []*MethodGenerator }
type SwitchGenerator ¶
type SwitchGenerator struct { GoGenerator SwitchMetaData SwitchGeneratorMetaData }
func NewSwitchGenerator ¶
func NewSwitchGenerator(varName string) (*SwitchGenerator, error)
func (*SwitchGenerator) Case ¶
func (gen *SwitchGenerator) Case(caseGenerator CaseGenerator)
func (*SwitchGenerator) Default ¶
func (gen *SwitchGenerator) Default(caseDefaultGenerator DefaultCaseGenerator)
func (*SwitchGenerator) Render ¶
func (gen *SwitchGenerator) Render() (string, error)
func (*SwitchGenerator) UseAssertion ¶
func (gen *SwitchGenerator) UseAssertion(ok bool)
type SwitchGeneratorMetaData ¶
type SwitchGeneratorMetaData struct { Cases []Case DefaultCase DefaultCase Var string Typed string }
type Type ¶
type Type interface { Render() (string, error) GetMethods() []*MethodGenerator }
type TypeReference ¶
type TypeReference interface { // GetImports returns the imports required to use this type. A struct, for example, // collects all the imports for its fields and itself. GetImports() []Import // GetName returns the go-syntax name of the type. GetName() string }
TypeReference represent a specific reference (either an interface, function, struct or global)
func NewUnsafeTypeReference ¶
func NewUnsafeTypeReference(t string) TypeReference
NewUnsafeTypeReference creates a (Unsafe) TypeReference from an string id
func TypeReferenceFromInstance ¶
func TypeReferenceFromInstance(t interface{}) TypeReference
TypeReferenceFromInstance creates a TypeReference from an instance of a variable
func TypeReferenceFromInstanceWithAlias ¶
func TypeReferenceFromInstanceWithAlias(t interface{}, alias string) TypeReference
TypeReferenceFromInstanceWithAlias creates a TypeReference from an instance of a variable with the given package alias
func TypeReferenceFromInstanceWithCustomName ¶
func TypeReferenceFromInstanceWithCustomName(t interface{}, name string) TypeReference
TypeReferenceFromInstanceWithCustomName creates a TypeReference from an instance of a variable with the given custom name, for use of a type alias's name rather than the underlying reflect type.