mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-12 05:38:04 +00:00
clean code
This commit is contained in:
parent
42120e1341
commit
3ea19ad2ed
@ -59,18 +59,15 @@ func uniqueBy(d *dataTreeNavigator, context Context, expressionNode *ExpressionN
|
|||||||
|
|
||||||
func getUniqueKeyValue(rhs Context) (string, error) {
|
func getUniqueKeyValue(rhs Context) (string, error) {
|
||||||
keyValue := "null"
|
keyValue := "null"
|
||||||
|
var err error
|
||||||
|
|
||||||
if rhs.MatchingNodes.Len() > 0 {
|
if rhs.MatchingNodes.Len() > 0 {
|
||||||
first := rhs.MatchingNodes.Front()
|
first := rhs.MatchingNodes.Front()
|
||||||
keyCandidate := first.Value.(*CandidateNode)
|
keyCandidate := first.Value.(*CandidateNode)
|
||||||
keyValue = keyCandidate.Value
|
keyValue = keyCandidate.Value
|
||||||
if keyCandidate.Kind != ScalarNode {
|
if keyCandidate.Kind != ScalarNode {
|
||||||
var err error
|
|
||||||
keyValue, err = encodeToString(keyCandidate, encoderPreferences{YamlFormat, 0})
|
keyValue, err = encodeToString(keyCandidate, encoderPreferences{YamlFormat, 0})
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return keyValue, err
|
||||||
return keyValue, nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user