Documentation
¶
Index ¶
- Constants
- func IsBinary(y *yaml.Node) bool
- func IsBool(y *yaml.Node) bool
- func IsFloat(y *yaml.Node) bool
- func IsInt(y *yaml.Node) bool
- func IsMap(y *yaml.Node) bool
- func IsNilType(y *yaml.Node) bool
- func IsOrderedMap(y *yaml.Node) bool
- func IsPairs(y *yaml.Node) bool
- func IsScalar(y *yaml.Node) bool
- func IsSequence(y *yaml.Node) bool
- func IsString(y *yaml.Node) bool
- func IsTimestamp(y *yaml.Node) bool
- func MapAppend(y *yaml.Node, k, v interface{}) error
- func MapAppendNode(y, k, v *yaml.Node) error
- func MapForEach(y *yaml.Node, fn func(k, v *yaml.Node) error) error
- func MapToYamlNode(val interface{}) (*yaml.Node, error)
- func NewBinaryNode(v []byte) *yaml.Node
- func NewBoolNode(v bool) *yaml.Node
- func NewFloatNode(val float64, rep byte, prec int) *yaml.Node
- func NewIntNode(val int64, base int) *yaml.Node
- func NewMapNode(size int) *yaml.Node
- func NewNullNode() *yaml.Node
- func NewOrderedMapNode(size int) *yaml.Node
- func NewPairsNode(size int) *yaml.Node
- func NewSequenceNode(size int) *yaml.Node
- func NewSetNode(size int) *yaml.Node
- func NewStringNode(v string) *yaml.Node
- func NewTimestampNode(v time.Time) *yaml.Node
- func RequireBinary(y *yaml.Node) error
- func RequireBool(y *yaml.Node) error
- func RequireFloat(y *yaml.Node) error
- func RequireInt(y *yaml.Node) error
- func RequireMap(y *yaml.Node) error
- func RequireNilType(y *yaml.Node) error
- func RequireOrderedMap(y *yaml.Node) error
- func RequirePairs(y *yaml.Node) error
- func RequireScalar(y *yaml.Node) error
- func RequireSequence(y *yaml.Node) error
- func RequireString(y *yaml.Node) error
- func RequireTimestamp(y *yaml.Node) error
- func ScalarToYamlNode(val interface{}) (*yaml.Node, error)
- func SequenceAppend(y *yaml.Node, v interface{}) error
- func SequenceAppendNode(y, v *yaml.Node) error
- func SequenceForEach(y *yaml.Node, fn func(v *yaml.Node) error) error
- func SliceToYamlNode(val interface{}) (*yaml.Node, error)
- func ToBinary(y *yaml.Node) ([]byte, error)
- func ToBoolean(y *yaml.Node) (bool, error)
- func ToFloat(y *yaml.Node) (float64, error)
- func ToInt(y *yaml.Node, base int) (int64, error)
- func ToScalarValue(y *yaml.Node) (interface{}, error)
- func ToString(y *yaml.Node) (string, error)
- func ToTime(y *yaml.Node, format string) (time.Time, error)
- func ToTime3339Nano(y *yaml.Node) (time.Time, error)
- func ToYamlNode(val interface{}) (*yaml.Node, error)
- type Marshaler
Constants ¶
const ( TagBinary = "tag:yaml.org,2002:binary" TagBool = "tag:yaml.org,2002:bool" TagFloat = "tag:yaml.org,2002:float" TagInt = "tag:yaml.org,2002:int" TagMerge = "tag:yaml.org,2002:merge" TagNil = "tag:yaml.org,2002:null" TagString = "tag:yaml.org,2002:str" TagTimestamp = "tag:yaml.org,2002:timestamp" TagValue = "tag:yaml.org,2002:value" TagYaml = "tag:yaml.org,2002:yaml" TagMap = "tag:yaml.org,2002:map" TagOrderedMap = "tag:yaml.org,2002:omap" TagPairs = "tag:yaml.org,2002:pairs" TagSet = "tag:yaml.org,2002:set" TagSequence = "tag:yaml.org,2002:seq" )
YAML type tags.
Variables ¶
This section is empty.
Functions ¶
func IsBinary ¶
func IsBinary(y *yaml.Node) bool
IsBinary returns whether the given YAML node is a binary node.
func IsBool ¶
func IsBool(y *yaml.Node) bool
IsBool returns whether the given YAML node is a boolean node.
func IsFloat ¶
func IsFloat(y *yaml.Node) bool
IsFloat returns whether the given YAML node is a float node.
func IsInt ¶
func IsInt(y *yaml.Node) bool
IsInt returns whether the given YAML node is an int node.
func IsNilType ¶
func IsNilType(y *yaml.Node) bool
IsNilType returns whether the given YAML node is a nil typed node.
func IsOrderedMap ¶
func IsOrderedMap(y *yaml.Node) bool
IsOrderedMap returns whether the given YAML node is an ordered map node.
func IsPairs ¶
func IsPairs(y *yaml.Node) bool
IsPairs returns whether the given YAML node is a pairs node.
func IsScalar ¶
func IsScalar(y *yaml.Node) bool
IsScalar returns whether the given YAML node is a scalar type.
func IsSequence ¶
func IsSequence(y *yaml.Node) bool
IsSequence returns whether the given YAML node is a sequence node.
func IsString ¶
func IsString(y *yaml.Node) bool
IsString returns whether the given YAML node is a string node.
func IsTimestamp ¶
func IsTimestamp(y *yaml.Node) bool
IsTimestamp returns whether the given YAML node is a timestamp node.
func MapAppend ¶
func MapAppend(y *yaml.Node, k, v interface{}) error
MapAppend converts the given key/value args (k, v) to YAML nodes then appends them to the given map node (y).
func MapAppendNode ¶
func MapAppendNode(y, k, v *yaml.Node) error
MapAppendNode appends the given key/value nodes (k, v) to the given map node (y).
func MapForEach ¶
MapForEach calls the given function for each key/value pair in the given YAML map node.
Returns an error if the given YAML node is not a map type, or if the passed function itself returns an error.
func MapToYamlNode ¶
func MapToYamlNode(val interface{}) (*yaml.Node, error)
MapToYamlNode converts the given map to a YAML node.
Returns an error if the given value is not a map, if the map key type is not a scalar value, or if the map contains a value which cannot be automatically converted to a YAML node (such as a struct value).
func NewBinaryNode ¶
func NewBinaryNode(v []byte) *yaml.Node
NewBinaryNode returns a new binary typed YAML node with the given content.
func NewBoolNode ¶
func NewBoolNode(v bool) *yaml.Node
NewBoolNode returns a new boolean typed YAML node with the given value.
func NewFloatNode ¶
NewFloatNode returns a new float typed YAML node with the given value.
func NewIntNode ¶
NewIntNode returns a new int typed YAML node with the given value.
func NewMapNode ¶
func NewMapNode(size int) *yaml.Node
NewMapNode returns a new mapping typed YAML node presized to the given size.
func NewOrderedMapNode ¶
func NewOrderedMapNode(size int) *yaml.Node
NewOrderedMapNode returns a new ordered map typed YAML node presized to the given size.
func NewPairsNode ¶
func NewPairsNode(size int) *yaml.Node
NewPairsNode returns a new pairs typed YAML node presized to the given size.
func NewSequenceNode ¶
func NewSequenceNode(size int) *yaml.Node
NewSequenceNode returns a new sequence typed YAML node presized to the given size.
func NewSetNode ¶
func NewSetNode(size int) *yaml.Node
NewSetNode returns a new set typed YAML node presized to the given size.
func NewStringNode ¶
func NewStringNode(v string) *yaml.Node
NewStringNode returns a new string typed YAML node with the given value.
func NewTimestampNode ¶
NewTimestampNode returns a new timestamp typed YAML node with the given value.
func RequireBinary ¶
func RequireBinary(y *yaml.Node) error
RequireBinary returns an error if the given node is not of type binary.
func RequireBool ¶
func RequireBool(y *yaml.Node) error
RequireBool returns an error if the given node is not of type bool.
func RequireFloat ¶
func RequireFloat(y *yaml.Node) error
RequireFloat returns an error if the given node is not of type float.
func RequireInt ¶
func RequireInt(y *yaml.Node) error
RequireInt returns an error if the given node is not of type int.
func RequireMap ¶
func RequireMap(y *yaml.Node) error
RequireMap returns an error if the given node is not a mapping node.
func RequireNilType ¶
func RequireNilType(y *yaml.Node) error
RequireNilType returns an error if the given node is not of type null.
func RequireOrderedMap ¶
func RequireOrderedMap(y *yaml.Node) error
RequireOrderedMap returns an error if the given node is not of type omap.
func RequirePairs ¶
func RequirePairs(y *yaml.Node) error
RequirePairs returns an error if the given node is not of type pairs.
func RequireScalar ¶
func RequireScalar(y *yaml.Node) error
RequireScalar returns an error if the given node is not a scalar node.
func RequireSequence ¶
func RequireSequence(y *yaml.Node) error
RequireSequence returns an error if the given node is not a sequence node.
func RequireString ¶
func RequireString(y *yaml.Node) error
RequireString returns an error if the given node is not of type string.
func RequireTimestamp ¶
func RequireTimestamp(y *yaml.Node) error
RequireTimestamp returns an error if the given node is not of type timestamp.
func ScalarToYamlNode ¶
func ScalarToYamlNode(val interface{}) (*yaml.Node, error)
ScalarToYamlNode converts the given scalar node to a YAML node.
Returns an error if the given value cannot be converted to a YAML scalar node.
func SequenceAppend ¶
func SequenceAppend(y *yaml.Node, v interface{}) error
SequenceAppend converts the given value (v) to a YAML node, then appends it to the given list node (y).
func SequenceAppendNode ¶
func SequenceAppendNode(y, v *yaml.Node) error
SequenceAppendNode appends the given YAML node value to the given sequence node.
func SequenceForEach ¶
SequenceForEach calls the given function for each value in the given YAML sequence node.
Returns an error if the given YAML node is not a sequence type, or if the passed function itself returns an error.
func SliceToYamlNode ¶
func SliceToYamlNode(val interface{}) (*yaml.Node, error)
SliceToYamlNode converts the given slice or array value into a YAML sequence.
Returns an error if the given value is not an array or slice, or if the array/slice contains a value that cannot be automatically converted to a YAML node (such as a struct value).
func ToScalarValue ¶
func ToScalarValue(y *yaml.Node) (interface{}, error)
ToScalarValue attempts to parse the given YAML node into a scalar value.
Handles types:
!!binary !!bool !!float !!int !!null !!str !!timestamp
func ToTime3339Nano ¶
ToTime3339Nano calls ToTime with the RFC3339Nano time format.
func ToYamlNode ¶
func ToYamlNode(val interface{}) (*yaml.Node, error)
ToYamlNode converts arbitrary typed data to a YAML node.
Note: This method is a shorthand call for all 3 of ScalarToYamlNode, SliceToYamlNode, and MapToYamlNode. As such it follows the same rules and cannot handle user defined types such as structs.
Types ¶
type Marshaler ¶
type Marshaler interface { // ToYAML provides a way to convert non-builtin types to YAML nodes using the // utilities in the xyml package. ToYAML() (*yaml.Node, error) }
Marshaler provides a way for xyml's YAML utilities to convert custom types into YAML nodes suitable for use with go-yaml v3.