Documentation
¶
Overview ¶
Package typeset handles type stringification and automatic struct aliasing.
A type is "normalized" when all of its previous aliases are resolved, function signature receivers are moved into the first function parameter and all inline struct declarations are replaced with generated aliases.
Normalized types are always assignable to their unnormalized counterparts and vice versa.
TypeSet allows handling all this in a cached manner.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TypeSet ¶
type TypeSet struct {
// contains filtered or unexported fields
}
TypeSet handles stringification and automatic aliasing of types.
Note that TypeSet includes any function receivers in its stringification (which differs from Go's types package).
TypeSet also automatically creates aliases for struct types so that their strings are kept small. You can query all created aliases with TypeSet.Aliases.
func (*TypeSet) Aliases ¶
Aliases returns all aliased structs, sorted by name. Use types.TypeString(Alias.Type, TypeSet.Qualifier) to obtain the code for the referenced struct.
func (*TypeSet) ContainsAlias ¶
ContainsAlias returns true if the given type is a struct alias within this type set. If ContainsAlias returned true, t is guaranteed to be of type *types.Alias.
func (*TypeSet) Normalized ¶
Normalized returns the normalized version of typ. Cached for future calls.