Skip to content

refactor: migrate from gopkg.in/yaml to go.yaml.in/yaml/v4#2704

Merged
markphelps merged 4 commits intomainfrom
modernize-again
Feb 9, 2026
Merged

refactor: migrate from gopkg.in/yaml to go.yaml.in/yaml/v4#2704
markphelps merged 4 commits intomainfrom
modernize-again

Conversation

@markphelps
Copy link
Copy Markdown
Contributor

@markphelps markphelps commented Feb 9, 2026

Summary

  • Replace unmaintained gopkg.in/yaml.v2 and yaml.v3 with the official YAML organization's maintained fork at go.yaml.in/yaml/v4
  • Apply Go modernizer fixes across the codebase
  • Add modernize linter to golangci-lint CI checks

YAML Migration Changes

  • Update all imports from gopkg.in/yaml.v2/v3 to go.yaml.in/yaml/v4
  • Fix type assertions in UnmarshalYAML: map[any]any -> map[string]any (yaml v4 returns map[string]any for mappings)
  • Update test expectation for yaml.Marshal indentation (v4 uses 4-space indentation by default)

Modernizer Changes

  • Use modern Go idioms and builtins (e.g., slices package, range int)
  • Simplify error handling patterns
  • Clean up redundant code

CI Changes

  • Add modernize linter to .golangci.yaml to catch future modernization opportunities automatically

Reference

Replace unmaintained gopkg.in/yaml.v2 and yaml.v3 with the official
YAML organization's maintained fork at go.yaml.in/yaml/v4.

Changes:
- Update all imports from gopkg.in/yaml.v2/v3 to go.yaml.in/yaml/v4
- Fix type assertions in UnmarshalYAML: map[any]any -> map[string]any
  (yaml v4 returns map[string]any for mappings, not map[any]any)
- Update test expectation for yaml.Marshal indentation
  (v4 uses 4-space indentation by default)
- Simplify overwrite_yaml.go using Go 1.21+ builtins (max, range int)

The go.yaml.in/yaml/v4 library is maintained by the official YAML
organization after go-yaml was marked unmaintained in April 2025.
@markphelps markphelps requested a review from a team as a code owner February 9, 2026 21:31
Apply automated modernizer fixes across the codebase:
- Use modern Go idioms and builtins (e.g., slices package, range int)
- Simplify error handling patterns
- Clean up redundant code
Enable the 'modernize' linter in golangci-lint to automatically catch
code that can be simplified using modern Go language and library features.

This will flag opportunities to use:
- Range over integers (Go 1.22+)
- slices/maps package functions
- Other modern Go idioms
Signed-off-by: Mark Phelps <[email protected]>
@markphelps markphelps enabled auto-merge (squash) February 9, 2026 21:50
@markphelps markphelps merged commit 8c3b931 into main Feb 9, 2026
32 checks passed
@markphelps markphelps deleted the modernize-again branch February 9, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants