mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
21 lines
423 B
Go
21 lines
423 B
Go
package treeops
|
|
|
|
import "gopkg.in/yaml.v3"
|
|
|
|
func BuildCandidateNodeFrom(token *Token) *CandidateNode {
|
|
var node yaml.Node = yaml.Node{Kind: yaml.ScalarNode}
|
|
node.Value = token.StringValue
|
|
|
|
switch token.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}
|
|
}
|