Просмотр исходного кода

Rename Node.Children to Node.Content.

Gustavo Niemeyer 7 лет назад
Родитель
Сommit
af7a659b0a
4 измененных файлов с 91 добавлено и 92 удалено
  1. 21 22
      decode.go
  2. 5 5
      encode.go
  3. 63 63
      node_test.go
  4. 2 2
      yaml.go

+ 21 - 22
decode.go

@@ -8,7 +8,6 @@ import (
 	"math"
 	"reflect"
 	"strconv"
-	"strings"
 	"time"
 )
 
@@ -168,7 +167,7 @@ func (p *parser) node(kind NodeKind, defaultTag, tag, value string) *Node {
 
 func (p *parser) parseChild(parent *Node) *Node {
 	child := p.parse()
-	parent.Children = append(parent.Children, child)
+	parent.Content = append(parent.Content, child)
 	return child
 }
 
@@ -425,9 +424,9 @@ func (d *decoder) unmarshal(n *Node, out reflect.Value) (good bool) {
 }
 
 func (d *decoder) document(n *Node, out reflect.Value) (good bool) {
-	if len(n.Children) == 1 {
+	if len(n.Content) == 1 {
 		d.doc = n
-		d.unmarshal(n.Children[0], out)
+		d.unmarshal(n.Content[0], out)
 		return true
 	}
 	return false
@@ -634,7 +633,7 @@ func settableValueOf(i interface{}) reflect.Value {
 }
 
 func (d *decoder) sequence(n *Node, out reflect.Value) (good bool) {
-	l := len(n.Children)
+	l := len(n.Content)
 
 	var iface reflect.Value
 	switch out.Kind() {
@@ -657,7 +656,7 @@ func (d *decoder) sequence(n *Node, out reflect.Value) (good bool) {
 	j := 0
 	for i := 0; i < l; i++ {
 		e := reflect.New(et).Elem()
-		if ok := d.unmarshal(n.Children[i], e); ok {
+		if ok := d.unmarshal(n.Content[i], e); ok {
 			out.Index(j).Set(e)
 			j++
 		}
@@ -672,13 +671,13 @@ func (d *decoder) sequence(n *Node, out reflect.Value) (good bool) {
 }
 
 func (d *decoder) mapping(n *Node, out reflect.Value) (good bool) {
-	l := len(n.Children)
+	l := len(n.Content)
 	if d.uniqueKeys {
 		nerrs := len(d.terrors)
 		for i := 0; i < l; i += 2 {
-			ni := n.Children[i]
+			ni := n.Content[i]
 			for j := i + 2; j < l; j += 2 {
-				nj := n.Children[j]
+				nj := n.Content[j]
 				if ni.Kind == nj.Kind && ni.Value == nj.Value {
 					d.terrors = append(d.terrors, fmt.Sprintf("line %d: mapping key %#v already defined at line %d", nj.Line, nj.Value, ni.Line))
 				}
@@ -724,12 +723,12 @@ func (d *decoder) mapping(n *Node, out reflect.Value) (good bool) {
 		out.Set(reflect.MakeMap(outt))
 	}
 	for i := 0; i < l; i += 2 {
-		if isMerge(n.Children[i]) {
-			d.merge(n.Children[i+1], out)
+		if isMerge(n.Content[i]) {
+			d.merge(n.Content[i+1], out)
 			continue
 		}
 		k := reflect.New(kt).Elem()
-		if d.unmarshal(n.Children[i], k) {
+		if d.unmarshal(n.Content[i], k) {
 			kkind := k.Kind()
 			if kkind == reflect.Interface {
 				kkind = k.Elem().Kind()
@@ -738,7 +737,7 @@ func (d *decoder) mapping(n *Node, out reflect.Value) (good bool) {
 				failf("invalid map key: %#v", k.Interface())
 			}
 			e := reflect.New(et).Elem()
-			if d.unmarshal(n.Children[i+1], e) {
+			if d.unmarshal(n.Content[i+1], e) {
 				out.SetMapIndex(k, e)
 			}
 		}
@@ -752,9 +751,9 @@ func isStringMap(n *Node) bool {
 	if n.Kind != MappingNode {
 		return false
 	}
-	l := len(n.Children)
+	l := len(n.Content)
 	for i := 0; i < l; i++ {
-		if n.Children[i].ShortTag() != strTag {
+		if n.Content[i].ShortTag() != strTag {
 			return false
 		}
 	}
@@ -785,11 +784,11 @@ func (d *decoder) mappingStruct(n *Node, out reflect.Value) (good bool) {
 		doneFields = make([]bool, len(sinfo.FieldsList))
 	}
 	name := settableValueOf("")
-	l := len(n.Children)
+	l := len(n.Content)
 	for i := 0; i < l; i += 2 {
-		ni := n.Children[i]
+		ni := n.Content[i]
 		if isMerge(ni) {
-			d.merge(n.Children[i+1], out)
+			d.merge(n.Content[i+1], out)
 			continue
 		}
 		if !d.unmarshal(ni, name) {
@@ -809,13 +808,13 @@ func (d *decoder) mappingStruct(n *Node, out reflect.Value) (good bool) {
 			} else {
 				field = d.fieldByIndex(n, out, info.Inline)
 			}
-			d.unmarshal(n.Children[i+1], field)
+			d.unmarshal(n.Content[i+1], field)
 		} else if sinfo.InlineMap != -1 {
 			if inlineMap.IsNil() {
 				inlineMap.Set(reflect.MakeMap(inlineMap.Type()))
 			}
 			value := reflect.New(elemType).Elem()
-			d.unmarshal(n.Children[i+1], value)
+			d.unmarshal(n.Content[i+1], value)
 			inlineMap.SetMapIndex(name, value)
 		} else if d.knownFields {
 			d.terrors = append(d.terrors, fmt.Sprintf("line %d: field %s not found in type %s", ni.Line, name.String(), out.Type()))
@@ -839,8 +838,8 @@ func (d *decoder) merge(n *Node, out reflect.Value) {
 		d.unmarshal(n, out)
 	case SequenceNode:
 		// Step backwards as earlier nodes take precedence.
-		for i := len(n.Children) - 1; i >= 0; i-- {
-			ni := n.Children[i]
+		for i := len(n.Content) - 1; i >= 0; i-- {
+			ni := n.Content[i]
 			if ni.Kind == AliasNode {
 				if ni.Alias != nil && ni.Alias.Kind != MappingNode {
 					failWantMap()

+ 5 - 5
encode.go

@@ -423,7 +423,7 @@ func (e *encoder) node(node *Node) {
 		yaml_document_start_event_initialize(&e.event, nil, nil, true)
 		e.event.head_comment = []byte(node.HeadComment)
 		e.emit()
-		for _, node := range node.Children {
+		for _, node := range node.Content {
 			e.node(node)
 		}
 		yaml_document_end_event_initialize(&e.event, true)
@@ -438,7 +438,7 @@ func (e *encoder) node(node *Node) {
 		e.must(yaml_sequence_start_event_initialize(&e.event, []byte(node.Anchor), []byte(tag), tag == "", style))
 		e.event.head_comment = []byte(node.HeadComment)
 		e.emit()
-		for _, node := range node.Children {
+		for _, node := range node.Content {
 			e.node(node)
 		}
 		e.must(yaml_sequence_end_event_initialize(&e.event))
@@ -455,9 +455,9 @@ func (e *encoder) node(node *Node) {
 		e.event.head_comment = []byte(node.HeadComment)
 		e.emit()
 
-		for i := 0; i+1 < len(node.Children); i += 2 {
-			e.node(node.Children[i])
-			e.node(node.Children[i+1])
+		for i := 0; i+1 < len(node.Content); i += 2 {
+			e.node(node.Content[i])
+			e.node(node.Content[i+1])
 		}
 
 		yaml_mapping_end_event_initialize(&e.event)

+ 63 - 63
node_test.go

@@ -19,7 +19,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  "null",
 				Tag:    "!!null",
@@ -33,7 +33,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  "foo",
 				Tag:    "!!str",
@@ -47,7 +47,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Style:  yaml.DoubleQuotedStyle,
 				Value:  "foo",
@@ -62,7 +62,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Style:  yaml.SingleQuotedStyle,
 				Value:  "foo",
@@ -77,7 +77,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Style:  yaml.TaggedStyle,
 				Value:  "123",
@@ -93,7 +93,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  "gIGC",
 				Tag:    "!!binary",
@@ -108,7 +108,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  "123",
 				Tag:    "!!str",
@@ -122,7 +122,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Style:  yaml.TaggedStyle,
 				Value:  "123",
@@ -137,7 +137,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  "123",
 				Tag:    "!tag:something",
@@ -151,7 +151,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.MappingNode,
 				Style:  yaml.TaggedStyle | yaml.FlowStyle,
 				Tag:    "!tag:something",
@@ -165,7 +165,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.MappingNode,
 				Style:  yaml.FlowStyle,
 				Tag:    "!tag:something",
@@ -179,7 +179,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Style:  yaml.TaggedStyle | yaml.FlowStyle,
 				Tag:    "!tag:something",
@@ -193,7 +193,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Style:  yaml.FlowStyle,
 				Tag:    "!tag:something",
@@ -207,7 +207,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Style:  yaml.SingleQuotedStyle,
 				Value:  "",
@@ -222,7 +222,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Style:  yaml.LiteralStyle,
 				Value:  "foo\nbar\n",
@@ -237,7 +237,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  "true",
 				Tag:    "!!bool",
@@ -251,7 +251,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  "-10",
 				Tag:    "!!int",
@@ -265,7 +265,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  "4294967296",
 				Tag:    "!!int",
@@ -279,7 +279,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  "0.1000",
 				Tag:    "!!float",
@@ -293,7 +293,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  "-.inf",
 				Tag:    "!!float",
@@ -307,7 +307,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.ScalarNode,
 				Value:  ".nan",
 				Tag:    "!!float",
@@ -321,7 +321,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.MappingNode,
 				Style:  yaml.FlowStyle,
 				Value:  "",
@@ -336,13 +336,13 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.MappingNode,
 				Value:  "",
 				Tag:    "!!map",
 				Line:   1,
 				Column: 1,
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:   yaml.ScalarNode,
 					Value:  "a",
 					Tag:    "!!str",
@@ -363,12 +363,12 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.MappingNode,
 				Tag:    "!!map",
 				Line:   1,
 				Column: 1,
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:   yaml.ScalarNode,
 					Value:  "a",
 					Tag:    "!!str",
@@ -379,7 +379,7 @@ var nodeTests = []struct {
 					Tag:    "!!map",
 					Line:   2,
 					Column: 3,
-					Children: []*yaml.Node{{
+					Content: []*yaml.Node{{
 						Kind:   yaml.ScalarNode,
 						Value:  "b",
 						Tag:    "!!str",
@@ -413,13 +413,13 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Value:  "",
 				Tag:    "!!seq",
 				Line:   1,
 				Column: 1,
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:   yaml.ScalarNode,
 					Value:  "a",
 					Tag:    "!!str",
@@ -440,12 +440,12 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Tag:    "!!seq",
 				Line:   1,
 				Column: 1,
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:   yaml.ScalarNode,
 					Value:  "a",
 					Tag:    "!!str",
@@ -456,7 +456,7 @@ var nodeTests = []struct {
 					Tag:    "!!seq",
 					Line:   2,
 					Column: 3,
-					Children: []*yaml.Node{{
+					Content: []*yaml.Node{{
 						Kind:   yaml.ScalarNode,
 						Value:  "b",
 						Tag:    "!!str",
@@ -478,14 +478,14 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Style:  yaml.FlowStyle,
 				Value:  "",
 				Tag:    "!!seq",
 				Line:   1,
 				Column: 1,
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:   yaml.ScalarNode,
 					Value:  "a",
 					Tag:    "!!str",
@@ -506,12 +506,12 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Tag:    "!!seq",
 				Line:   1,
 				Column: 1,
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:   yaml.ScalarNode,
 					Value:  "a",
 					Tag:    "!!str",
@@ -523,7 +523,7 @@ var nodeTests = []struct {
 					Style:  yaml.FlowStyle,
 					Line:   2,
 					Column: 3,
-					Children: []*yaml.Node{{
+					Content: []*yaml.Node{{
 						Kind:   yaml.ScalarNode,
 						Value:  "b",
 						Tag:    "!!str",
@@ -545,12 +545,12 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   1,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.MappingNode,
 				Line:   1,
 				Column: 1,
 				Tag:    "!!map",
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:   yaml.ScalarNode,
 					Value:  "a",
 					Tag:    "!!str",
@@ -615,7 +615,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   3,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:        yaml.ScalarNode,
 				Value:       "true",
 				Tag:         "!!bool",
@@ -634,7 +634,7 @@ var nodeTests = []struct {
 			Column:      1,
 			HeadComment: "# DH1\n\n# DH2",
 			FootComment: "# DF1\n\n# DF2",
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:        yaml.ScalarNode,
 				Value:       "true",
 				Tag:         "!!bool",
@@ -653,12 +653,12 @@ var nodeTests = []struct {
 			Column:      1,
 			HeadComment: "# DH1\n\n# DH2",
 			FootComment: "# DF1\n\n# DF2",
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.MappingNode,
 				Tag:    "!!map",
 				Line:   7,
 				Column: 1,
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:        yaml.ScalarNode,
 					Line:        7,
 					Column:      1,
@@ -699,12 +699,12 @@ var nodeTests = []struct {
 			Column:      1,
 			HeadComment: "# DH1\n\n# DH2",
 			FootComment: "# DF1\n\n# DF2",
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Tag:    "!!seq",
 				Line:   7,
 				Column: 1,
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:        yaml.ScalarNode,
 					Tag:         "!!str",
 					Line:        7,
@@ -732,12 +732,12 @@ var nodeTests = []struct {
 			Line:        3,
 			Column:      1,
 			HeadComment: "# DH1",
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Tag:    "!!seq",
 				Line:   3,
 				Column: 1,
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:        yaml.ScalarNode,
 					Tag:         "!!str",
 					Line:        3,
@@ -762,12 +762,12 @@ var nodeTests = []struct {
 			Column:      1,
 			HeadComment: "# DH1",
 			FootComment: "# DF1",
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.MappingNode,
 				Tag:    "!!map",
 				Line:   4,
 				Column: 1,
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:        yaml.ScalarNode,
 					Tag:         "!!str",
 					Line:        4,
@@ -779,7 +779,7 @@ var nodeTests = []struct {
 					Tag:    "!!map",
 					Line:   6,
 					Column: 3,
-					Children: []*yaml.Node{{
+					Content: []*yaml.Node{{
 						Kind:        yaml.ScalarNode,
 						Tag:         "!!str",
 						Line:        6,
@@ -791,7 +791,7 @@ var nodeTests = []struct {
 						Line:   9,
 						Column: 3,
 						Tag:    "!!seq",
-						Children: []*yaml.Node{{
+						Content: []*yaml.Node{{
 							Kind:        yaml.ScalarNode,
 							Tag:         "!!str",
 							Line:        9,
@@ -821,7 +821,7 @@ var nodeTests = []struct {
 			Kind:   yaml.DocumentNode,
 			Line:   2,
 			Column: 1,
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:        yaml.SequenceNode,
 				Tag:         "!!seq",
 				Style:       yaml.FlowStyle,
@@ -830,7 +830,7 @@ var nodeTests = []struct {
 				HeadComment: "# H1",
 				LineComment: "# I",
 				FootComment: "# F1",
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:   yaml.ScalarNode,
 					Tag:    "!!str",
 					Line:   2,
@@ -853,7 +853,7 @@ var nodeTests = []struct {
 			Column:      1,
 			HeadComment: "# DH1",
 			FootComment: "# DF1",
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:        yaml.SequenceNode,
 				Tag:         "!!seq",
 				Style:       yaml.FlowStyle,
@@ -861,7 +861,7 @@ var nodeTests = []struct {
 				Column:      1,
 				HeadComment: "# SH1",
 				FootComment: "# SF1",
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:        yaml.ScalarNode,
 					Tag:         "!!str",
 					Line:        6,
@@ -890,7 +890,7 @@ var nodeTests = []struct {
 			Column:      1,
 			HeadComment: "# DH1",
 			FootComment: "# DF1",
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:        yaml.SequenceNode,
 				Tag:         "!!seq",
 				Style:       yaml.FlowStyle,
@@ -898,7 +898,7 @@ var nodeTests = []struct {
 				Column:      1,
 				HeadComment: "# SH1",
 				FootComment: "# SF1",
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:        yaml.ScalarNode,
 					Tag:         "!!str",
 					Line:        6,
@@ -925,7 +925,7 @@ var nodeTests = []struct {
 			Column:      1,
 			HeadComment: "# DH1",
 			FootComment: "# DF1",
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:        yaml.MappingNode,
 				Tag:         "!!map",
 				Style:       yaml.FlowStyle,
@@ -933,7 +933,7 @@ var nodeTests = []struct {
 				Column:      1,
 				HeadComment: "# MH1",
 				FootComment: "# MF1",
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:        yaml.ScalarNode,
 					Tag:         "!!str",
 					Line:        6,
@@ -974,7 +974,7 @@ var nodeTests = []struct {
 			Column:      1,
 			HeadComment: "# DH1",
 			FootComment: "# DF1",
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:        yaml.MappingNode,
 				Tag:         "!!map",
 				Style:       yaml.FlowStyle,
@@ -982,7 +982,7 @@ var nodeTests = []struct {
 				Column:      1,
 				HeadComment: "# MH1",
 				FootComment: "# MF1",
-				Children: []*yaml.Node{{
+				Content: []*yaml.Node{{
 					Kind:        yaml.ScalarNode,
 					Tag:         "!!str",
 					Line:        6,
@@ -1021,12 +1021,12 @@ var nodeTests = []struct {
 			Column:      1,
 			HeadComment: "# DH1\n\n# DH2",
 			FootComment: "# DF1\n\n# DF2",
-			Children: []*yaml.Node{{
+			Content: []*yaml.Node{{
 				Kind:   yaml.SequenceNode,
 				Tag:    "!!seq",
 				Line:   7,
 				Column: 1,
-				Children: []*yaml.Node{
+				Content: []*yaml.Node{
 					saveNode("x", &yaml.Node{
 						Kind:        yaml.ScalarNode,
 						Tag:         "!!str",

+ 2 - 2
yaml.go

@@ -334,8 +334,8 @@ type Node struct {
 	// Alias holds the node that this alias points to. Only valid when Kind is AliasNode.
 	Alias    *Node
 
-	// Children holds contained nodes for documents, mappings, and sequences.
-	Children []*Node
+	// Content holds contained nodes for documents, mappings, and sequences.
+	Content []*Node
 
 	// HeadComment holds any comments in the lines preceding the node and
 	// not separated by an empty line.