Skip to content

Commit a325207

Browse files
authored
Replace last github.com/goccy/go-yaml with go.yaml.in/yaml/v3 (#55582)
### What does this PR do? Replace `github.com/goccy/go-yaml` with `go.yaml.in/yaml/v3` in the 3 test files that use it, and drop the now-unused dependency from `go.mod`. ### Motivation Finish removing one of our many YAML dependencies, therefore completing: - #46070. `goccy/go-yaml`'s main [stated rationale](https://github.com/goccy/go-yaml#why-a-new-library) for existing was that `go-yaml/yaml` was unmaintained and offered no AST-level access for reversible transformations. Both are addressed today: `go.yaml.in/yaml` is the actively maintained fork, and its `yaml.Node` type supports the same tag, comment, and style preserving round-trip that `scanner_test.go` needed `goccy`'s `ast` and `token` packages for. ### Additional Notes As [spotted by Codex](#55582 (comment)), regenerating `testdata/symbols.yaml` was unavoidable because `go.yaml.in/yaml/v3`'s encoder has no public option to reproduce `goccy`'s exact output: there is no way to add artificial indentation to a root-level sequence, and its scalar quoting is more canonical than `goccy'`s, only quoting where the YAML spec actually requires it. Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
1 parent c35c49a commit a325207

8 files changed

Lines changed: 793 additions & 827 deletions

File tree

deps/go.MODULE.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ use_repo(
158158
"com_github_go_viper_mapstructure_v2",
159159
"com_github_go_zookeeper_zk",
160160
"com_github_gobwas_glob",
161-
"com_github_goccy_go_yaml",
162161
"com_github_gocomply_scap",
163162
"com_github_godbus_dbus_v5",
164163
"com_github_godror_godror",

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ require (
280280
github.com/go-viper/mapstructure/v2 v2.5.0
281281
github.com/go-zookeeper/zk v1.0.4
282282
github.com/gobwas/glob v0.2.3
283-
github.com/goccy/go-yaml v1.19.2
284283
github.com/gocomply/scap v0.1.3
285284
github.com/godbus/dbus/v5 v5.2.2
286285
github.com/godror/godror v0.50.0
@@ -720,6 +719,7 @@ require (
720719
github.com/go-test/deep v1.1.1 // indirect
721720
github.com/gobuffalo/flect v1.0.3 // indirect
722721
github.com/goccy/go-json v0.10.6 // indirect
722+
github.com/goccy/go-yaml v1.19.2 // indirect
723723
github.com/gocql/gocql v1.6.0 // indirect
724724
github.com/godbus/dbus v4.1.0+incompatible // indirect
725725
github.com/godror/knownpb v0.3.0 // indirect

pkg/dyninst/gosymname/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ dd_agent_go_test(
3434
data = glob(["testdata/**"]),
3535
embed = [":gosymname"],
3636
deps = [
37-
"@com_github_goccy_go_yaml//:go-yaml",
3837
"@com_github_stretchr_testify//assert",
3938
"@com_github_stretchr_testify//require",
39+
"@in_yaml_go_yaml_v3//:yaml",
4040
],
4141
)

pkg/dyninst/gosymname/fuzz_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"os"
1010
"testing"
1111

12-
"github.com/goccy/go-yaml"
1312
"github.com/stretchr/testify/require"
13+
"go.yaml.in/yaml/v3"
1414
)
1515

1616
func FuzzParse(f *testing.F) {

pkg/dyninst/gosymname/symbol_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,16 @@
66
package gosymname
77

88
import (
9+
"bytes"
910
"flag"
1011
"fmt"
1112
"os"
1213
"strconv"
1314
"testing"
1415

15-
"github.com/goccy/go-yaml"
1616
"github.com/stretchr/testify/assert"
1717
"github.com/stretchr/testify/require"
18+
"go.yaml.in/yaml/v3"
1819
)
1920

2021
// ---------------------------------------------------------------------------
@@ -212,8 +213,12 @@ func TestSymbols(t *testing.T) {
212213
Output: formatTestOutput(&s),
213214
})
214215
}
215-
out, err := yaml.MarshalWithOptions(cases, yaml.IndentSequence(true))
216-
require.NoError(t, err)
216+
var buf bytes.Buffer
217+
enc := yaml.NewEncoder(&buf)
218+
enc.SetIndent(2)
219+
require.NoError(t, enc.Encode(cases))
220+
require.NoError(t, enc.Close())
221+
out := buf.Bytes()
217222
require.NoError(t, os.WriteFile(path, out, 0644))
218223
t.Logf("rewrote %s with %d cases", path, len(cases))
219224
return

0 commit comments

Comments
 (0)