yq/pkg/yqlib/treeops/value_node_builder.go

21 lines
417 B
Go
Raw Normal View History

2020-10-16 01:47:31 +00:00
package treeops
import "gopkg.in/yaml.v3"
func BuildCandidateNodeFrom(p *PathElement) *CandidateNode {
var node yaml.Node = yaml.Node{Kind: yaml.ScalarNode}
node.Value = p.StringValue
switch p.Value.(type) {
case float32, float64:
node.Tag = "!!float"
case int, int64, int32:
node.Tag = "!!int"
case bool:
node.Tag = "!!bool"
case string:
node.Tag = "!!str"
}
return &CandidateNode{Node: &node}
}