From c10bfe06025e9a23d221d206ccf2b140e8cb3de5 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Thu, 10 Jul 2025 13:00:56 +1000 Subject: [PATCH] Switching to YAML org supported go-yaml --- go.mod | 2 +- go.sum | 2 ++ pkg/yqlib/candidate_node_yaml.go | 2 +- pkg/yqlib/decoder_yaml.go | 2 +- pkg/yqlib/encoder_yaml.go | 2 +- pkg/yqlib/yaml_test.go | 7 +++++++ release_notes.txt | 1 + 7 files changed, 14 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index be12dcbd..2d90570f 100644 --- a/go.mod +++ b/go.mod @@ -17,10 +17,10 @@ require ( github.com/spf13/cobra v1.9.1 github.com/spf13/pflag v1.0.6 github.com/yuin/gopher-lua v1.1.1 + go.yaml.in/yaml/v3 v3.0.4 golang.org/x/net v0.41.0 golang.org/x/text v0.26.0 gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 - gopkg.in/yaml.v3 v3.0.1 ) require ( diff --git a/go.sum b/go.sum index 0d2831e4..a3abc319 100644 --- a/go.sum +++ b/go.sum @@ -49,6 +49,8 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M= github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/pkg/yqlib/candidate_node_yaml.go b/pkg/yqlib/candidate_node_yaml.go index c80af2a2..14beb073 100644 --- a/pkg/yqlib/candidate_node_yaml.go +++ b/pkg/yqlib/candidate_node_yaml.go @@ -3,7 +3,7 @@ package yqlib import ( "fmt" - yaml "gopkg.in/yaml.v3" + yaml "go.yaml.in/yaml/v3" ) func MapYamlStyle(original yaml.Style) Style { diff --git a/pkg/yqlib/decoder_yaml.go b/pkg/yqlib/decoder_yaml.go index c17f9029..070b1658 100644 --- a/pkg/yqlib/decoder_yaml.go +++ b/pkg/yqlib/decoder_yaml.go @@ -8,7 +8,7 @@ import ( "regexp" "strings" - yaml "gopkg.in/yaml.v3" + yaml "go.yaml.in/yaml/v3" ) type yamlDecoder struct { diff --git a/pkg/yqlib/encoder_yaml.go b/pkg/yqlib/encoder_yaml.go index f198c052..8c65899f 100644 --- a/pkg/yqlib/encoder_yaml.go +++ b/pkg/yqlib/encoder_yaml.go @@ -9,7 +9,7 @@ import ( "strings" "github.com/fatih/color" - "gopkg.in/yaml.v3" + "go.yaml.in/yaml/v3" ) type yamlEncoder struct { diff --git a/pkg/yqlib/yaml_test.go b/pkg/yqlib/yaml_test.go index acb978a0..903035a0 100644 --- a/pkg/yqlib/yaml_test.go +++ b/pkg/yqlib/yaml_test.go @@ -84,6 +84,13 @@ var yamlFormatScenarios = []formatScenario{ } var yamlParseScenarios = []expressionScenario{ + // { + // description: "with a unquoted question mark in the string", + // document: "foo: {bar: a?bc}", + // expected: []string{ + // "D0, P[], (!!map)::a: hello # things\n", + // }, + // }, { document: `a: hello # things`, expected: []string{ diff --git a/release_notes.txt b/release_notes.txt index c1d0b431..fbf4ba3c 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -2,6 +2,7 @@ - Added INI support - Fixed 'add' operator when piped in with no data #2378, #2383, #2384 - Fixed delete after slice problem (bad node path) #2387 Thanks @antoinedeschenes + - Switched to YAML org supported go-yaml! - Bumped dependencies