package yaml

import "cuelang.org/go/internal/encoding/yaml"

Index

Functions

func Encode

func Encode(n ast.Node) (b []byte, err error)

Encode converts a CUE AST to YAML.

The given file must only contain values that can be directly supported by YAML:

Type          Restrictions
BasicLit
File          no imports, aliases, or definitions
StructLit     no embeddings, aliases, or definitions
List
Field         must be regular; label must be a BasicLit or Ident
CommentGroup

TODO: support anchors through Ident.

func Unmarshal

func Unmarshal(filename string, data []byte) (ast.Expr, error)

Unmarshal parses a single YAML value to a CUE expression.

Types

type Decoder

type Decoder interface {
	// Decode consumes a YAML value and returns it in CUE syntax tree node.
	Decode() (ast.Expr, error)
}

Decoder is a temporary interface compatible with both the old and new yaml decoders.

func NewDecoder

func NewDecoder(filename string, b []byte) Decoder

NewDecoder is a temporary constructor compatible with both the old and new yaml decoders. Note that the signature matches the new yaml decoder, as the old signature can only error when reading a source that isn't []byte.

Source Files

decode.go encode.go

Version
v0.10.0-0.dev
Published
Jun 6, 2024
Platform
js/wasm
Imports
18 packages
Last checked
22 minutes ago

Tools for package owners.