Documentation
¶
Index ¶
- Constants
- func FilterTypeName(exp ast.Expr) (fieldType string, fieldCanBeCompareWithNil bool, ...)
- func FormatTypeDeclaration(tparams *ast.FieldList) (string, error)
- func FormatTypeParams(tparams *ast.FieldList) string
- func IsExported(arg reflect.Value) bool
- func Main()
- func Usage()
- type File
- type Generator
- type Package
- type Struct
- type StructField
- type TmplUnionRender
- type Value
Constants ¶
View Source
const ( TagUnion = "union" TagUnionFlagShort = "short" // `union:",short"` )
Variables ¶
This section is empty.
Functions ¶
func FilterTypeName ¶
func FormatTypeDeclaration ¶
FormatTypeDeclaration turns TypeParamList into its Go representation, such as: [T, Y comparable]. Note that it does not print constraints as this is mainly used for formatting type params in method receivers.
func FormatTypeParams ¶
FormatTypeParams turns TypeParamList into its Go representation, such as: [T, Y]. Note that it does not print constraints as this is mainly used for formatting type params in method receivers.
func IsExported ¶
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File holds a single parsed file and associated data.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator holds the state of the analysis. Primarily used to buffer the output for format.Source.
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
Package holds a single parsed package and associated files and ast files.
type Struct ¶
type Struct struct { FileImports []string // The import path of the file contains the struct StructTypeImport string // The import path of StructTypeName. StructTypeName string // The StructTypeName of the struct. StructTypeGenericDeclaration string // the Generic type of the struct type StructTypeGenericTypeParams string // the Generic params of the struct type IsStruct bool Fields []StructField }
Struct represents a declared constant.
type StructField ¶
type StructField struct { FieldName string // The FieldName of the struct field. FieldType string // The FieldType of the struct field. FieldDocComment *ast.CommentGroup // The doc comment of the struct field. FieldLineComment *ast.CommentGroup // The line comment of the struct field. UnionTag reflect_.SubStructTag // The UnionTag of the struct field. FieldCanBeCompareWithNil bool // The FieldType of the struct field can be compared with nil. FieldCanBeCompareWithZero bool // The FieldType of the struct field can be compared with zero. }
type TmplUnionRender ¶
type TmplUnionRender struct { // Print the header and package clause. GoUnionToolName string GoUnionToolArgs []string GoUnionToolArgsJoined string PackageName string ImportPaths []string ValDecls []string TargetTypeName string // type name of target type TargetTypeImport string // import path of target type TargetTypeGenericDeclaration string // the Generic type of the struct type TargetTypeGenericParams string // the Generic params of the struct type FormatTypeName string // The format FieldName of the struct type. Fields []StructField // fields if target type is struct UnionInterfaceName string // union interface name of target type UnionStructName string // union struct name of target type ApplyUnionsAsMemberFunction bool // ApplyUnions can be registered as UnionType's member function WithTargetTypeNameAsPrefix bool // WithXXX() can be generated as {{UnionType}}WithXXX() }
func (*TmplUnionRender) Complete ¶
func (t *TmplUnionRender) Complete()
Click to show internal directories.
Click to hide internal directories.