yaml

package
v0.11.0-alpha.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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 NewDecoder added in v0.9.0

func NewDecoder(filename string, b []byte) *decoder

NewDecoder creates a decoder for YAML values to extract CUE syntax tree nodes.

The filename is used for position information in CUE syntax tree nodes as well as any errors encountered while decoding YAML.

func Unmarshal added in v0.9.0

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

Unmarshal parses a single YAML value to a CUE expression.

Types

type Decoder added in v0.9.0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL