API Reference
go-yaml
A YAML encoder and decoder for Go, developed as the yaml.v3 package used across the ecosystem.
Official Documentation ↗CompatibilityThis documentation covers version
v3.0. Check the official docs for the latest API surface.Installation
go
go get gopkg.in/yaml.v3Methods
No methods match this filter.
go-yaml marshals Go values to YAML and unmarshals YAML into Go structs using field tags.
Key Features
- Struct mapping via yaml tags
- Node API preserving comments and style
- Streaming encoder and decoder
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://pkg.go.dev/gopkg.in/yaml.v3 · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:54.461Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- If an error is returned by MarshalYAML, the marshaling procedure stops and returns with the provided error. (https://pkg.go.dev/gopkg.in/yaml.v3)
- When this error is returned, the value is still unmarshaled partially. (https://pkg.go.dev/gopkg.in/yaml.v3)
FAQ
- How do I rename fields?
- Add yaml struct tags such as yaml:"name" on each exported field you want to rename.
- Does it preserve comments?
- The Node API does, letting you decode into a yaml.Node, edit, and re-encode while keeping comments.
- How do I emit multiple documents?
- Reuse a single Encoder and call Encode per document; each call emits a --- separated document.
Report a problem with this API docOpens a pre-filled issue on GitHub.