Documentation ¶
Overview ¶
Package yamlnode allows for manipulation of YAML nodes using a dotted-path syntax.
Examples of dotted-path syntax:
- a.map.key
- b.items[1]
When using Set or Append, an optional qualifier `?` can be used in a path element to indicate that the node is conditionally present, and should be created if not present. A preceding bracket-pair, `[]`, can be used to indicate that a sequence node should be created.
Optional qualifier examples:
- a?.map.key - if 'a' is not present, it will be created
- a.map?.key - if 'map' is not present, it will be created
- b.items[]? - if 'items' is not present, it will be created as a sequence
The special characters in a dotted-path syntax are:
- `.` (dot) - separates key elements
- `[` (open bracket) - used in sequences
- `]` (close bracket) - used in sequences
- `?` (question mark) - optional qualifier
- `"` (double quote) - used to indicate a quoted-string
If these special characters are part of a key, the key can be surrounded as a quoted-string using `"` (double quotes) to indicate their literalness. If a `"` (double-quote) character is also part of the key, a preceding backslash `\"` may be used to escape it.
Quoted-string examples:
- "esc.ape.d" -> esc.ape.d
- "\"hello\"..[world]" -> "hello"..[world]
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNodeNotFound = errors.New("node not found")
var ErrNodeWrongKind = errors.New("unexpected node kind")
ErrNodeWrongKind is returned when the node kind is not as expected. This error may be useful to detect nodes that have multiple possible kinds and need to be handled specially.
Functions ¶
func Append ¶
Append appends a node to the sequence node at the given path. If the node at the path is not a sequence node, ErrNodeWrongKind is returned.
An optional qualifier `?` can be used automatically create node(s) that are conditionally present; a preceding bracket-pair, `[]`, is used to indicate sequences.
Examples:
- a?.map.items - if 'a' is not present, it will be created
- b.items[]? - if 'items' is not present, it will be created as a sequence
Types ¶
This section is empty.