Documentation
¶
Index ¶
- Variables
- func AsYAML(v interface{}) string
- func FindNode(n *yaml.Node, path string) (*yaml.Node, error)
- func IsEmpty(it interface{}) bool
- func MarshalJSONOmitEmpty(e interface{}) ([]byte, error)
- func MarshalJSONOmitEmptyIndented(e interface{}) ([]byte, error)
- func Merge(a, b *yaml.Node) error
- func MergeMappingNode(a, b *yaml.Node) error
- func MergeSequenceNode(a, b *yaml.Node) error
- func MergeYAML(v interface{}, contents ...string) (nodes []*yaml.Node, err error)
- func MustMarshalJSONOmitEmpty(e interface{}) string
- func NewDocument() yaml.Node
- func Parse(reader io.Reader) (yaml.Node, error)
- func ParseFile(f string) (yaml.Node, error)
- func ParseString(s string) (yaml.Node, error)
- func ReadYAMLFiles(v interface{}, files ...string) ([]*yaml.Node, error)
- func RemoveEmptyAny(e interface{}) (map[string]interface{}, error)
- func RemoveEmptyFromMap(it interface{}) interface{}
- func Write(doc yaml.Node, writer io.Writer) error
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotFound = errors.New("no such node")
)
Functions ¶
func FindNode ¶
Get returns the node at the given path. The format of the path is similar to JSON path but simpler. It works only with mapping nodes. e.g. node1.node2 returns node2 and node1 must be a mapping node.
func IsEmpty ¶
func IsEmpty(it interface{}) bool
IsEmpty returns true if it is nil, "", 0, or its lenghth is zero.
func MarshalJSONOmitEmpty ¶
MarshalJSONOmitEmpty mashals a given value as a JSON omitting all empty values
func MarshalJSONOmitEmptyIndented ¶
MarshalJSONOmitEmptyIndented mashals a given value as a JSON omitting all empty values
func Merge ¶
func Merge(a, b *yaml.Node) error
Merge tries to merge two yaml nodes a and b into a. It merges the nodes with the same kind.
func MergeMappingNode ¶
func MergeMappingNode(a, b *yaml.Node) error
MergeMappingNode tries to merge two yaml nodes a and b into a. If it encounters incompatible nodes along the way, it returns error. We need to go through all content of a map and check whether the key is there. If yes, we merge it recursively, otherwise just append new key
func MergeSequenceNode ¶
func MergeSequenceNode(a, b *yaml.Node) error
MergeSequenceNode attempts to merge two sequence nodes, a and b, into node a. Corresponding items are merged recursively. If the corresponding item is a scalar value, the item in 'a' is replaced with the corresponding item in 'b'. Any items in 'b' that come after the last item in 'a' are appended to 'a'.
func MustMarshalJSONOmitEmpty ¶
func MustMarshalJSONOmitEmpty(e interface{}) string
MustMarshalJSONOmitEmpty is a sugar version of MustMarshalJSONOmitEmpty.
func NewDocument ¶
func NewDocument() yaml.Node
NewDocument creates a new document node based on mapping.
func ParseString ¶
ParseString parses a YAML document from a string.
func ReadYAMLFiles ¶
ReadYAMLFiles reads files in the given order and merge them. A later file will overwrite the previous yaml data.
func RemoveEmptyAny ¶
RemoveEmptyAny marshals a given e into a string, unmarshal back to a map and then remove empty objects.
func RemoveEmptyFromMap ¶
func RemoveEmptyFromMap(it interface{}) interface{}
RemoveEmptyFromMap recursively removes empty values from a map.
Types ¶
This section is empty.