go-openapi go-yaml

A YAML 1.2 parser, decoder and encoder for Go, with a syntax tree that keeps positions, comments and the source text of every token.

Status

Experimental. There is no tagged release and the API still moves — see Status.

Getting started

go get github.com/go-openapi/go-yaml

Then read Which layer you need.

Licensing

SPDX-FileCopyrightText: Copyright 2025 go-swagger maintainers

This library ships under the Apache-2.0 license.

Contributing

Issues and pull requests welcome.

See the shared go-openapi contributing guidelines.


  • Install go-yaml, decode a document, encode one back.

    And decide which of the two APIs you need: the codec, or the parser and the AST.

  • Read, query and change a YAML document without turning it into Go values.

    Key order, comments, positions, non-string keys and numbers Go cannot hold — all of it survives, because nothing is projected onto a Go type.

  • The codec: turning YAML into Go values and back.

    Marshal and Unmarshal, the options that steer them, struct tags, anchors, comments and errors.

  • Why this library exists, how correct it is, how fast it is, and what is not built yet.
  • Repo-level information for github.com/go-openapi/go-yaml.

    Contributing guidelines and maintainer documentation are shared across the go-openapi organization.