Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Any = TypeFromString("any") Bool = TypeFromString("bool") Char = TypeFromString("char") Data = TypeFromString("data") Number = TypeFromString("number") String = TypeFromString("string") AnyArray = NewArray(Any) BoolArray = NewArray(Bool) NumberArray = NewArray(Number) StringArray = NewArray(String) AnyMap = NewMap(Any) NumberMap = NewMap(Number) StringMap = NewMap(String) ErrorInterface = NewInterface("error.Error", map[string]*Type{ "Error": String, }) )
Functions ¶
This section is empty.
Types ¶
type Kind ¶
type Kind int
const ( // An unresolved interface (object type) is named, but the properties will // be nil because they are not known. This is a distinction from a resolved // interface which allowed to have zero or more properties. // // KindUnresolvedInterface = 0 on purpose it acts as a fallthrough/unknown // type. KindUnresolvedInterface Kind = iota KindResolvedInterface // Basic types. KindAny KindBool KindChar KindData KindNumber KindString // Other. KindArray KindMap KindFunc )
type Registry ¶ added in v0.24.0
A Registry holds a collection of unique types that can are referenced internally to allow for circular references but also be serializable.
func (Registry) Add ¶ added in v0.24.0
Add will merge new types into the register. An error is returned only if an unresolved interface type is added and there's no way to resolve it right now.
func (Registry) EqualTypeSlices ¶ added in v0.24.0
func (Registry) EqualTypes ¶ added in v0.24.0
EqualTypes ignores only the Name.
type Type ¶
type Type struct { // Kind will not be set when Ref is supplied. Kind Kind `json:",omitempty"` // Name is used as the descriptive name for the object. Name string `json:",omitempty"` // Element is used when Kind is an Array or Map. Element *Type `json:",omitempty"` // Argument and Returns are used when Kind is a Func. Either may be nil. Arguments, Returns []*Type `json:",omitempty"` // Properties is used for KindInterface Properties map[string]*Type `json:",omitempty"` // Ref is used when types are flattened for a Registry. It will point to an // index of another type in the registry. Ref string `json:",omitempty"` }
Type represents a data type.
func NewUnresolvedInterface ¶
func TypeFromString ¶
TypeFromString decodes a syntactically-valid type from a string.
func (*Type) SortedPropertyNames ¶ added in v0.24.0
Click to show internal directories.
Click to hide internal directories.