Skip to content

Commit 810868b

Browse files
committed
chore: drop yaml v2
Signed-off-by: Joseph Kato <joseph@jdkato.io>
1 parent 20fcb4d commit 810868b

3 files changed

Lines changed: 5 additions & 34 deletions

File tree

‎go.mod‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ require (
3030
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
3131
golang.org/x/net v0.47.0
3232
golang.org/x/sys v0.38.0
33-
gopkg.in/yaml.v2 v2.4.0
33+
gopkg.in/yaml.v3 v3.0.1
3434
)
3535

3636
require (
@@ -64,5 +64,5 @@ require (
6464
golang.org/x/term v0.37.0 // indirect
6565
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
6666
gopkg.in/neurosnap/sentences.v1 v1.0.7 // indirect
67-
gopkg.in/yaml.v3 v3.0.1 // indirect
67+
gopkg.in/yaml.v2 v2.4.0 // indirect
6868
)

‎internal/check/definition.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
"github.com/errata-ai/regexp2"
1111
"github.com/mitchellh/mapstructure"
12-
"gopkg.in/yaml.v2"
12+
"gopkg.in/yaml.v3"
1313

1414
"github.com/errata-ai/vale/v3/internal/core"
1515
"github.com/errata-ai/vale/v3/internal/nlp"

‎internal/core/view.go‎

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/pelletier/go-toml/v2"
1212
v2dasel "github.com/tomwright/dasel/v2"
1313
"github.com/tomwright/dasel/v3"
14-
yamlv2 "gopkg.in/yaml.v2"
1514
"gopkg.in/yaml.v3"
1615
)
1716

@@ -66,7 +65,7 @@ func NewView(path string) (*View, error) {
6665
return nil, err
6766
}
6867

69-
err = yamlv2.Unmarshal(data, &view)
68+
err = yaml.Unmarshal(data, &view)
7069
if err != nil {
7170
return nil, err
7271
}
@@ -348,38 +347,10 @@ func fileToValue(f *File) (DaselValue, []scalarPos, error) {
348347
return nil, nil, errors.New("unsupported file type")
349348
}
350349

351-
value, isMap := normalize(raw).(map[string]any)
350+
value, isMap := raw.(map[string]any)
352351
if !isMap {
353352
return nil, nil, errors.New("document root is not an object")
354353
}
355354

356355
return value, scalars, nil
357356
}
358-
359-
// normalize recursively converts map[interface{}]interface{} (produced by
360-
// gopkg.in/yaml.v2) to map[string]any so that Dasel v3 can traverse the
361-
// document without choking on interface{} map keys.
362-
func normalize(v any) any {
363-
switch val := v.(type) {
364-
case map[interface{}]interface{}:
365-
out := make(map[string]any, len(val))
366-
for k, v := range val {
367-
out[fmt.Sprintf("%v", k)] = normalize(v)
368-
}
369-
return out
370-
case map[string]any:
371-
out := make(map[string]any, len(val))
372-
for k, v := range val {
373-
out[k] = normalize(v)
374-
}
375-
return out
376-
case []any:
377-
out := make([]any, len(val))
378-
for i, v := range val {
379-
out[i] = normalize(v)
380-
}
381-
return out
382-
default:
383-
return val
384-
}
385-
}

0 commit comments

Comments
 (0)