From c573d2a63bd2384db8d91f2704f6d8249139117c Mon Sep 17 00:00:00 2001 From: Lars Stegman Date: Mon, 19 May 2025 11:30:23 +0200 Subject: [PATCH] fix: don't overwrite value --- pkg/yqlib/candidate_node_goccy_yaml.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/pkg/yqlib/candidate_node_goccy_yaml.go b/pkg/yqlib/candidate_node_goccy_yaml.go index 17541d3f..b71bf591 100644 --- a/pkg/yqlib/candidate_node_goccy_yaml.go +++ b/pkg/yqlib/candidate_node_goccy_yaml.go @@ -422,21 +422,19 @@ func (m *goccyMarshaller) marshalScalar(path string, o *CandidateNode) (ast.Scal return n, nil } - switch av := v.(type) { + var n ast.ScalarNode + switch v.(type) { case float64: - n := ast.Float(scalarToken) - n.Value = av - return n, nil + n = ast.Float(scalarToken) case int64: - n := ast.Integer(scalarToken) - n.Value = av - return n, nil + n = ast.Integer(scalarToken) case bool: - n := ast.Bool(scalarToken) - n.Value = av - return n, nil + n = ast.Bool(scalarToken) case string: - n := ast.String(scalarToken) + n = ast.String(scalarToken) + } + + if n != nil { n.SetPath(path) return n, nil }