Skip to content

Commit 2d78bea

Browse files
authored
chore: replace yaml parser with goccy/go-yaml for stricter decoding (#84)
Switch from gopkg.in/yaml.v3 to github.com/goccy/go-yaml, due to yaml.v3 is deprecated
1 parent 05527dc commit 2d78bea

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/sv-tools/mock-http-server
33
go 1.24.0
44

55
require (
6+
github.com/goccy/go-yaml v1.17.1
67
github.com/spf13/pflag v1.0.6
78
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6
8-
gopkg.in/yaml.v3 v3.0.1
99
)

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1+
github.com/goccy/go-yaml v1.17.1 h1:LI34wktB2xEE3ONG/2Ar54+/HJVBriAGJ55PHls4YuY=
2+
github.com/goccy/go-yaml v1.17.1/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
13
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
24
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
35
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 h1:y5zboxd6LQAqYIhHnB48p0ByQ/GnQx2BE33L8BOHQkI=
46
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6/go.mod h1:U6Lno4MTRCDY+Ba7aCcauB9T60gsv5s4ralQzP72ZoQ=
5-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
6-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
7-
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
8-
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"syscall"
1212
"time"
1313

14+
"github.com/goccy/go-yaml"
1415
flag "github.com/spf13/pflag"
1516
"golang.org/x/exp/slog"
16-
"gopkg.in/yaml.v3"
1717
)
1818

1919
func main() {
@@ -41,8 +41,7 @@ func main() {
4141
}
4242

4343
var config Config
44-
d := yaml.NewDecoder(f)
45-
d.KnownFields(true)
44+
d := yaml.NewDecoder(f, yaml.DisallowUnknownField())
4645
if err := d.Decode(&config); err != nil {
4746
log.Error("decoding config failed", err)
4847
os.Exit(1)

0 commit comments

Comments
 (0)