github.com/goki/ki@v1.1.11/kit/README.md (about) 1 # kit 2 3 [![Go Report Card](https://goreportcard.com/badge/github.com/goki/ki/kit)](https://goreportcard.com/report/github.com/goki/ki/kit) 4 [![GoDoc](https://godoc.org/github.com/goki/ki/kit?status.svg)](http://godoc.org/github.com/goki/ki/kit) 5 6 Package `kit` provides various reflect type functions for GoKi system (KiType = KiT = kit -- also a bit of a "kit" collection of low-level system functions), including: 7 8 * `kit.TypeRegistry (types.go)` for associating string names with 9 `reflect.Type` values, to allow dynamic marshaling of structs, and also 10 bidirectional string conversion of const int iota (enum) types. It is used 11 by the GoKi ki system, hence the kit (ki types) name. 12 13 To register a new type, add: 14 15 ```Go 16 var KiT_TypeName = kit.Types.AddType(&TypeName{}, [props|nil]) 17 ``` 18 19 where the props is a `map[string]interface{}` of optional properties that can 20 be associated with the type -- this is used in the GoGi graphical interface 21 system for example to color objects of different types using the 22 background-color property. KiT_TypeName variable can be conveniently used 23 wherever a reflect.Type of that type is needed. 24 25 * `kit.EnumRegistry (enums.go)` that registers constant int iota (aka enum) types, and 26 provides general conversion utilities to / from string, int64, general 27 properties associated with enum types, and deals with bit flags 28 29 * `kit.Type (type.go)` struct provides JSON and XML Marshal / Unmarshal functions for 30 saving / loading reflect.Type using registrered type names. 31 32 * `convert.go`: robust interface{}-based type conversion routines that are 33 useful in more lax user-interface contexts where "common sense" conversions 34 between strings, numbers etc are useful 35 36 * `embeds.go`: various functions for managing embedded struct types, e.g., 37 determining if a given type embeds another type (directly or indirectly), 38 and iterating over fields to flatten the otherwise nested nature of the 39 field encoding in embedded types.