Documentation ¶
Overview ¶
The data package has various ways to work with generic data. It was designed for YAML data, but many of the same functions are useful for generic mappings and such.
Index ¶
- Constants
- func AsBool(data interface{}) (b bool, ok bool)
- func AsFloat(data interface{}) (f float64, ok bool)
- func AsInt(data interface{}) (i int, ok bool)
- func AsInt64(data interface{}) (i int64, ok bool)
- func AsUint(data interface{}) (i uint, ok bool)
- func AsUint64(data interface{}) (i uint64, ok bool)
- type Constructor
- type ConstructorFunc
- type ConstructorMap
- type Map
- type Schema
- type SchemaFunc
- type Sequence
Constants ¶
const ( StringTag = parser.DefaultPrefix + "str" SequenceTag = parser.DefaultPrefix + "seq" MappingTag = parser.DefaultPrefix + "map" NullTag = parser.DefaultPrefix + "null" BoolTag = parser.DefaultPrefix + "bool" IntTag = parser.DefaultPrefix + "int" FloatTag = parser.DefaultPrefix + "float" )
Canonical YAML tags
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Constructor ¶
type Constructor parser.Constructor
A Constructor converts a Node into a Go data structure.
var DefaultConstructor Constructor = ConstructorMap{ StringTag: ConstructorFunc(constructStr), SequenceTag: ConstructorFunc(constructSeq), MappingTag: ConstructorFunc(constructMap), NullTag: ConstructorFunc(constructNull), BoolTag: ConstructorFunc(constructBool), IntTag: ConstructorFunc(constructInt), FloatTag: ConstructorFunc(constructFloat), }
DefaultConstructor constructs all of the core data types.
type ConstructorFunc ¶
ConstructorFunc is a function that implements the Constructor interface.
type ConstructorMap ¶
type ConstructorMap map[string]Constructor
ConstructorMap uses constructors associated with string tags to construct a value.
type Map ¶
type Map map[interface{}]interface{}
Map is an unordered collection of values associated with key values.
func (Map) SetDefault ¶
func (m Map) SetDefault(k, d interface{}) (v interface{})
SetDefault adds a new key to a map if the key isn't already present, and returns the latest value for the key.
type Schema ¶
A Schema determines the tag for a node without an explicit tag.
var ( FailsafeSchema Schema = SchemaFunc(failsafeSchema) CoreSchema = SchemaFunc(coreSchema) )
Schemas from the YAML 1.2 specification
type SchemaFunc ¶
SchemaFunc is a function type that fulfills the Schema interface.