Repository navigation
chore(deps): update module go.yaml.in/yaml/v3 to v4 - #265
Open
renovate[bot] wants to merge 1 commit into
Open
renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
v3.0.6→v4.0.0Release Notes
yaml/go-yaml (go.yaml.in/yaml/v3)
v4.0.0: go-yaml v4.0.0Compare Source
go-yaml v4.0.0
go-yaml v4.0.0 is the first stable release of the v4 series, maintained by the
YAML organization.
It adds configurable loading and dumping, public plugin interfaces, structured
errors, and a CLI for inspecting YAML processing.
The classic APIs remain supported, so applications can adopt v4 incrementally.
Getting started
Install the release:
Use this import path in your Go code:
For an existing v3 application, start by updating imports, reviewing custom
unmarshalers, and running your tests.
You can continue using
Unmarshal,Marshal,NewDecoder, andNewEncoder.The v2 and v3 APIs remain frozen, with security fixes only; new features and
routine bug fixes are developed in v4.
Why add Load and Dump?
Applications need different YAML policies: strict configuration validation,
particular output layouts, or custom anchor handling.
The new
LoadandDumpfunctions and streamingLoaderandDumperacceptfunctional options and plugins for those choices.
They use YAML's load/dump terminology and are recommended for new code.
The classic entry points keep compatibility settings rather than changing
formatting and error presentation for every existing caller.
Moving to the new API is an explicit choice to use v4 defaults, with presets
available when you want older settings.
Classic APIs remain supported.
For example, load a configuration with strict field checking, then choose its
output indentation:
Unknown struct fields are ignored by default;
WithKnownFields()opts intorejecting them.
Duplicate mapping keys are rejected by default.
Options apply in order, so later options override earlier settings.
Defaults and compatibility
Quoting still depends on scalar content and styles, and line width is a
preference rather than a guaranteed maximum.
NewDecoderuses v3 error formatting;NewEncoderretains v3 output settingswith v4 error formatting.
Choose
WithV3Defaults()to select compatibility defaults through the new API.When replacing
Marshal, also disable wrapping to match its line-width setting:Presets select defaults; they do not reverse every v4 bug fix or reproduce every
legacy code path.
For example, package-level
Loadrequires exactly one document, whereasUnmarshalretains legacy handling of empty input and trailing content.WithSingleDocument()deliberately skips validation of later documents.Use
WithAllDocuments()to load or dump slices as document streams, or use astreaming loader or dumper to process documents individually.
Options, plugins, and nodes
Options control indentation, sequence layout, quoting, document markers,
Unicode escaping, field validation, and more.
OptsYAMLaccepts YAML configuration for supported settings, which can also beshared with the CLI.
The public plugin APIs cover six areas:
merge algorithm.
dotted paths, or reject alias references.
The core module provides implementations for these APIs.
Additional parsers live in separate modules, keeping their dependencies optional.
Existing depth and alias protections remain enabled by default.
yaml.Nodegives access to tags, styles, comments, anchors, and source positions.Node.LoadandNode.Dumpaccept options for node conversion.Pass construction options explicitly inside custom unmarshaler hooks;
Node.Loadstarts with fresh defaults independently of its calling loader.Stream nodes can expose encoding and YAML directives.
Node output retains supported styles and comments without promising identical
source formatting.
Migration details to check
NewLoaderandNewDumperreturn errors; check them before using the stream.Check dumper
DumpandCloseerrors as well.Custom
UnmarshalYAML(*yaml.Node) errorhooks must use the v4 node type.Recognized v3 node hooks produce a migration error rather than silently losing
custom behavior.
The legacy
UnmarshalYAML(func(any) error) errorcallback remains supported.Conversion failures return structured
*yaml.LoadErrorsvalues.Use
errors.Asto inspect structured errors or match legacy*yaml.TypeErrorvalues, rather than relying on a direct type assertion or fixed message text.
Review the migration guide
for the complete compatibility guidance.
Inspect YAML with the CLI
Install the CLI from this release:
Convert to JSON, inspect nodes, or examine scanner and parser output:
The CLI also supports reusable options files and pipelines between intermediate
stages, making small bug reports easier to reproduce.
Runtime plugin selection chooses implementations already linked into the binary.
Further reading and thanks
See the options guide,
plugin guide,
CLI guide,
and API reference.
Please report problems with minimal input, a reproducer, and your Go version in
the issue tracker.
Release-candidate users should update to v4.0.0 and rerun their tests, as some APIs
changed during prerelease development.
Thanks to everyone who tested, reported problems, and contributed to this release.
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.