clean code

This commit is contained in:
Mike Farah 2024-06-15 17:06:17 +10:00
parent 42120e1341
commit 3ea19ad2ed

View File

@ -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, nil return keyValue, err
} }