Documentation ¶
Index ¶
- func IsIdentical(lhs, rhs types.Type) bool
- func IsPointer(T types.Type) bool
- func IsSlice(T types.Type) bool
- func IsStruct(T types.Type) bool
- func IsUnderlyingError(T types.Type) bool
- func IsUnderlyingIdentical(lhs, rhs types.Type) bool
- func New(fn Generator) error
- func NewInterfaceMethods(T types.Type) map[string]*Func
- func NewTypeName(T types.Type) *types.TypeName
- func NewUnderlyingType(T types.Type) types.Type
- func NormFunc(name string, fn *types.Func) *types.Func
- func NormFuncFromTypes(name string, param, result types.Type) *types.Func
- func UnderlyingSignature(T types.Type) string
- func UnderlyingString(T types.Type, q types.Qualifier) string
- func Walk(visitor Visitor, T types.Type) bool
- type Func
- type FuncArg
- type Generator
- type InterfaceVisitor
- type NamedVisitor
- type Option
- type OptionItem
- type StructField
- type StructFields
- type StructVisitor
- type Tag
- type TypeNames
- type UnderlyingVisitor
- func (u UnderlyingVisitor) IsArray() (bool, int64)
- func (u UnderlyingVisitor) IsPointer() bool
- func (u UnderlyingVisitor) IsSlice() bool
- func (u UnderlyingVisitor) Obj() *types.TypeName
- func (u UnderlyingVisitor) Pkg() *types.Package
- func (u UnderlyingVisitor) Type() types.Type
- func (u UnderlyingVisitor) Underlying() types.Type
- func (v *UnderlyingVisitor) Visit(T types.Type) bool
- type Visitor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsIdentical ¶
func IsUnderlyingError ¶
func IsUnderlyingIdentical ¶
func NewUnderlyingType ¶
NewUnderlyingType extracts the underlying type of a Type.
func UnderlyingSignature ¶
Types ¶
type Func ¶
type Func struct { Name string // pkg name can be different from package path, e.g. github.com/alextanhongpin/mapper/examples // can have package `main` instead of `examples`. Obj *types.TypeName Pkg string PkgPath string From *FuncArg To *FuncArg Error bool Fn *types.Func // Store the original Norm *Func // contains filtered or unexported fields }
func (*Func) NormalizedName ¶
func (*Func) RequiresInputPointer ¶
RequiresInputPointer returns true if the input needs to be converted into a pointer.
func (*Func) RequiresInputValue ¶
RequiresInputValue returns true if the input needs to be converted into a value.
type InterfaceVisitor ¶
type InterfaceVisitor struct {
// contains filtered or unexported fields
}
type NamedVisitor ¶
type NamedVisitor struct {
// contains filtered or unexported fields
}
func NewNamedVisitor ¶
func NewNamedVisitor(T types.Type) *NamedVisitor
func (NamedVisitor) Methods ¶
func (v NamedVisitor) Methods() map[string]*Func
func (NamedVisitor) Obj ¶
func (v NamedVisitor) Obj() *types.TypeName
func (NamedVisitor) Pkg ¶
func (v NamedVisitor) Pkg() *types.Package
type Option ¶
type Option struct { In string // The input path, with the file name, e.g. yourpath/yourfile.go Out string // The output path, with the mapper name, e.g. yourpath/yourfile_gen.go Pkg *types.Package PkgName string // The pkgName PkgPath string // The pkgPath Suffix string DryRun bool Prune bool Items []OptionItem }
type StructField ¶
type StructField struct { Name string `example:"Name"` // Useful when the output directory doesn't match the existing ones. Pkg string // e.g. yourpkg PkgPath string // e.g. github.com/your-org/yourpkg Exported bool // e.g. true Tag *Tag // e.g. `map:"RenameField,CustomFunction"` Ordinal int // The original position of the struct field. Type types.Type }
StructField for the example below.
type Foo struct { Name sql.NullString `json:"name" }
type StructFields ¶
type StructFields map[string]StructField
func NewStructFields ¶
func NewStructFields(T types.Type) StructFields
func (StructFields) WithTags ¶
func (s StructFields) WithTags() StructFields
type StructVisitor ¶
type StructVisitor struct {
// contains filtered or unexported fields
}
func NewStructVisitor ¶
func NewStructVisitor() *StructVisitor
type Tag ¶
type Tag struct { Name string FieldOrMethod rune // If the pkgPath is not set, we assume it to be the same as the current root directory. PkgPath string `example:"github.com/your.org/yourpkg"` Pkg string `example:"yourpkg"` // If the `pkg` is not empty, it could most likely be an interface or struct method. TypeName string `example:"YourStruct|YourInterface"` // If `pkg` is empty, then this is a pure function import. Func string `example:"YourMethod"` Tag string Ignore bool }
func (Tag) IsImported ¶
type UnderlyingVisitor ¶
type UnderlyingVisitor struct {
// contains filtered or unexported fields
}
func NewUnderlyingVisitor ¶
func NewUnderlyingVisitor(T types.Type) *UnderlyingVisitor
func (UnderlyingVisitor) IsArray ¶
func (u UnderlyingVisitor) IsArray() (bool, int64)
func (UnderlyingVisitor) IsPointer ¶
func (u UnderlyingVisitor) IsPointer() bool
func (UnderlyingVisitor) IsSlice ¶
func (u UnderlyingVisitor) IsSlice() bool
func (UnderlyingVisitor) Obj ¶
func (u UnderlyingVisitor) Obj() *types.TypeName
func (UnderlyingVisitor) Pkg ¶
func (u UnderlyingVisitor) Pkg() *types.Package
func (UnderlyingVisitor) Type ¶
func (u UnderlyingVisitor) Type() types.Type
func (UnderlyingVisitor) Underlying ¶
func (u UnderlyingVisitor) Underlying() types.Type
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
rename-field
rename demonstrates how to use the `map` tag to customize the name for the mapper.
|
rename demonstrates how to use the `map` tag to customize the name for the mapper. |
rename-method
rename demonstrates how to use the `map` tag to customize the name for the mapper.
|
rename demonstrates how to use the `map` tag to customize the name for the mapper. |
Click to show internal directories.
Click to hide internal directories.