Documentation
¶
Index ¶
- func HasMethods(pStruct Struct, methodNames ...string) bool
- func LoadPackages(packagePatterns ...string) (map[string]*types.Package, error)
- type Field
- type Struct
- type Typ
- type Type
- func (t Type) IsIterable() bool
- func (t Type) IsPointer() bool
- func (t Type) IsStruct() bool
- func (t Type) Name() string
- func (t Type) PackageName() string
- func (t Type) Position() int
- func (t Type) ToStructType() Struct
- func (t Type) Type() string
- func (t Type) TypeName() string
- func (t Type) UnqualifiedType() string
- func (t Type) UnqualifiedTypeName() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasMethods ¶
func LoadPackages ¶
Loads and type checks a package. Returns any errors encountered during loading or typechecking, otherwise returns the package's data. Useful for static type analysis with the types package instead of manually parsing the AST. A good explainer lives here: https://github.com/golang/example/tree/master/gotypes
Types ¶
type Field ¶
type Field struct {
Typ
// contains filtered or unexported fields
}
func (Field) IsLocalType ¶
Returns true if the field's type originates from the same package its parent struct is defined in.
type Struct ¶
type Struct struct {
Typ
// contains filtered or unexported fields
}
func ParseStructs ¶
We can iterate over the declarations at the package level a single time to extract all the data necessary for generation. Any new data that needs to be added to the struct definitions can be extracted here.
func (Struct) LocalTypes ¶
func (Struct) PrintWithFieldError ¶
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
func (Type) PackageName ¶
func (Type) ToStructType ¶
func (Type) TypeName ¶
Qualified type without array/slice/pointer prefix. e.g. *ccc.UUID -> ccc.UUID, []ccc.UUID -> ccc.UUID
func (Type) UnqualifiedType ¶
Type without package prefix. e.g. ccc.UUID -> UUID, []ccc.UUID -> []UUID
func (Type) UnqualifiedTypeName ¶
Type without array/slice/pointer or package prefix. e.g. *ccc.UUID -> UUID, []ccc.UUID -> UUID