Documentation
¶
Index ¶
- Constants
- func FilterTypeName(exp ast.Expr) (fieldType string, fieldIsMap bool, fieldSliceElt string)
- 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 TmplConfigRender
- type TmplOptionRender
- type Value
Constants ¶
View Source
const ( TagOption = "option" TagOptionFlagShort = "short" // `option:",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 ¶ added in v1.2.84
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
// contains filtered or unexported fields
}
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.
OptionTag reflect_.SubStructTag // The OptionTag of the struct field.
FieldIsMap bool // The FieldType of the struct field is a map.
FieldSliceElt string // slice elt type name, for ...type_of_slice_element
FormatFieldName string // The format FieldName of the struct field.
FormatFieldComments []string // The format comment of the struct field.
}
type TmplConfigRender ¶
type TmplConfigRender struct {
// Print the header and package clause.
GoOptionToolName string
GoOptionToolArgs []string
GoOptionToolArgsJoined 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
TrimmedTypeName string // trimmed type name of target type
OptionInterfaceName string // option interface name of target type
OptionStructName string // option struct name of target type
ApplyOptionsAsMemberFunction bool // ApplyOptions can be registered as OptionType's member function
}
func (*TmplConfigRender) Complete ¶
func (t *TmplConfigRender) Complete()
type TmplOptionRender ¶
type TmplOptionRender struct {
// Print the header and package clause.
GoOptionToolName string
GoOptionToolArgs []string
GoOptionToolArgsJoined 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
TrimmedTypeName string // trimmed type name of target type
FormatTypeName string // The format FieldName of the struct type.
Fields []StructField // fields if target type is struct
OptionInterfaceName string // option interface name of target type
OptionStructName string // option struct name of target type
ApplyOptionsAsMemberFunction bool // ApplyOptions can be registered as OptionType's member function
WithTargetTypeNameAsPrefix bool // WithXXX() can be generated as {{OptionType}}WithXXX()
}
func (*TmplOptionRender) Complete ¶
func (t *TmplOptionRender) Complete()
Click to show internal directories.
Click to hide internal directories.