Documentation
¶
Index ¶
- func HasInterface(pkg *types.Package, s Struct, interfaceName string) bool
- func LoadPackages(packagePatterns ...string) (map[string]*types.Package, error)
- type Field
- type Struct
- type TypeInfo
- func (t TypeInfo) IsIterable() bool
- func (t TypeInfo) IsPointer() bool
- func (t TypeInfo) IsStruct() bool
- func (t TypeInfo) Name() string
- func (t TypeInfo) PackageName() string
- func (t TypeInfo) Position() int
- func (t TypeInfo) ToStructType() Struct
- func (t TypeInfo) Type() string
- func (t TypeInfo) TypeName() string
- func (t TypeInfo) UnqualifiedType() string
- func (t TypeInfo) UnqualifiedTypeName() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasInterface ¶ added in v0.0.18
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 {
TypeInfo
// 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.
func (Field) ResolvedType ¶ added in v0.1.11
Returns the field's unqualified type if it's local, and the qualified type otherwise.
type Struct ¶
type Struct struct {
TypeInfo
// 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) Implements ¶ added in v0.0.18
func (Struct) LocalTypes ¶
func (Struct) PrintWithFieldError ¶
func (*Struct) SetInterface ¶ added in v0.0.18
type TypeInfo ¶ added in v0.0.18
type TypeInfo struct {
// contains filtered or unexported fields
}
func (TypeInfo) IsIterable ¶ added in v0.0.18
Returns true if type is slice or array
func (TypeInfo) PackageName ¶ added in v0.0.18
func (TypeInfo) ToStructType ¶ added in v0.0.18
func (TypeInfo) TypeName ¶ added in v0.0.18
Qualified type without array/slice/pointer prefix. e.g. *ccc.UUID -> ccc.UUID, []ccc.UUID -> ccc.UUID
func (TypeInfo) UnqualifiedType ¶ added in v0.0.18
Type without package prefix. e.g. ccc.UUID -> UUID, []ccc.UUID -> []UUID
func (TypeInfo) UnqualifiedTypeName ¶ added in v0.0.18
Type without array/slice/pointer or package prefix. e.g. *ccc.UUID -> UUID, []ccc.UUID -> UUID