yq/pkg/yqlib/operator_column.go

25 lines
553 B
Go
Raw Normal View History

2022-02-27 00:56:46 +00:00
package yqlib
import (
"container/list"
"fmt"
)
func columnOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
log.Debugf("columnOperator")
var results = list.New()
for el := context.MatchingNodes.Front(); el != nil; el = el.Next() {
candidate := el.Value.(*CandidateNode)
2023-04-08 10:17:13 +00:00
result := candidate.CreateReplacement()
result.Kind = ScalarNode
result.Value = fmt.Sprintf("%v", candidate.Column)
result.Tag = "!!int"
2022-02-27 00:56:46 +00:00
results.PushBack(result)
}
return context.ChildContext(results), nil
}