summaryrefslogtreecommitdiffstats
path: root/vendor/gopkg.in/yaml.v3/encode.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-10-19 23:40:00 +0200
committerGitHub <noreply@github.com>2020-10-19 23:40:00 +0200
commit075a84427f6332aab707d283ad770d69f8816032 (patch)
tree0ff9f56a057919f3fe968e57f6f0b1c0d1f85078 /vendor/gopkg.in/yaml.v3/encode.go
parent950f2759bd2b20aa0bdedc3dc9a74d0dafb606d8 (diff)
downloadmatterbridge-msglm-075a84427f6332aab707d283ad770d69f8816032.tar.gz
matterbridge-msglm-075a84427f6332aab707d283ad770d69f8816032.tar.bz2
matterbridge-msglm-075a84427f6332aab707d283ad770d69f8816032.zip
Update vendor (#1265)
Diffstat (limited to 'vendor/gopkg.in/yaml.v3/encode.go')
-rw-r--r--vendor/gopkg.in/yaml.v3/encode.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/vendor/gopkg.in/yaml.v3/encode.go b/vendor/gopkg.in/yaml.v3/encode.go
index 1f37271c..45e8d1e1 100644
--- a/vendor/gopkg.in/yaml.v3/encode.go
+++ b/vendor/gopkg.in/yaml.v3/encode.go
@@ -119,6 +119,9 @@ func (e *encoder) marshal(tag string, in reflect.Value) {
case *Node:
e.nodev(in)
return
+ case Node:
+ e.nodev(in.Addr())
+ return
case time.Time:
e.timev(tag, in)
return
@@ -422,18 +425,23 @@ func (e *encoder) nodev(in reflect.Value) {
}
func (e *encoder) node(node *Node, tail string) {
+ // Zero nodes behave as nil.
+ if node.Kind == 0 && node.IsZero() {
+ e.nilv()
+ return
+ }
+
// If the tag was not explicitly requested, and dropping it won't change the
// implicit tag of the value, don't include it in the presentation.
var tag = node.Tag
var stag = shortTag(tag)
- var rtag string
var forceQuoting bool
if tag != "" && node.Style&TaggedStyle == 0 {
if node.Kind == ScalarNode {
if stag == strTag && node.Style&(SingleQuotedStyle|DoubleQuotedStyle|LiteralStyle|FoldedStyle) != 0 {
tag = ""
} else {
- rtag, _ = resolve("", node.Value)
+ rtag, _ := resolve("", node.Value)
if rtag == stag {
tag = ""
} else if stag == strTag {
@@ -442,6 +450,7 @@ func (e *encoder) node(node *Node, tail string) {
}
}
} else {
+ var rtag string
switch node.Kind {
case MappingNode:
rtag = mapTag
@@ -471,7 +480,7 @@ func (e *encoder) node(node *Node, tail string) {
if node.Style&FlowStyle != 0 {
style = yaml_FLOW_SEQUENCE_STYLE
}
- e.must(yaml_sequence_start_event_initialize(&e.event, []byte(node.Anchor), []byte(tag), tag == "", style))
+ e.must(yaml_sequence_start_event_initialize(&e.event, []byte(node.Anchor), []byte(longTag(tag)), tag == "", style))
e.event.head_comment = []byte(node.HeadComment)
e.emit()
for _, node := range node.Content {
@@ -487,7 +496,7 @@ func (e *encoder) node(node *Node, tail string) {
if node.Style&FlowStyle != 0 {
style = yaml_FLOW_MAPPING_STYLE
}
- yaml_mapping_start_event_initialize(&e.event, []byte(node.Anchor), []byte(tag), tag == "", style)
+ yaml_mapping_start_event_initialize(&e.event, []byte(node.Anchor), []byte(longTag(tag)), tag == "", style)
e.event.tail_comment = []byte(tail)
e.event.head_comment = []byte(node.HeadComment)
e.emit()
@@ -528,11 +537,11 @@ func (e *encoder) node(node *Node, tail string) {
case ScalarNode:
value := node.Value
if !utf8.ValidString(value) {
- if tag == binaryTag {
+ if stag == binaryTag {
failf("explicitly tagged !!binary data must be base64-encoded")
}
- if tag != "" {
- failf("cannot marshal invalid UTF-8 data as %s", shortTag(tag))
+ if stag != "" {
+ failf("cannot marshal invalid UTF-8 data as %s", stag)
}
// It can't be encoded directly as YAML so use a binary tag
// and encode it as base64.
@@ -557,5 +566,7 @@ func (e *encoder) node(node *Node, tail string) {
}
e.emitScalar(value, node.Anchor, tag, style, []byte(node.HeadComment), []byte(node.LineComment), []byte(node.FootComment), []byte(tail))
+ default:
+ failf("cannot encode node with unknown kind %d", node.Kind)
}
}