yaml

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node interface {
	Type() TypeID
	// Tag returns a YAML tag if any.
	Tag() string
	// Contents returns the contents as further Node items. For maps, this will contain exactly two nodes, while
	// for sequences this will contain as many nodes as there are items. For strings, this will contain no items.
	Contents() []Node
	// MapKey selects a specific map key. If the node is not a map, this function panics.
	MapKey(key string) (Node, bool)
	// MapKeys lists all keys of a map. If the node is not a map, this function panics.
	MapKeys() []string
	// Value returns the value in case of a string node.
	Value() string
	// Raw outputs the node as raw data without type annotation.
	Raw() any
}

Node is a simplified representation of a YAML node.

func EmptyNode

func EmptyNode() Node

EmptyNode returns an empty node.

type Parser

type Parser interface {
	// Parse parses the provided value into the simplified node representation.
	Parse(data []byte) (Node, error)
}

Parser is a YAML parser that parses into a simplified value structure.

func New

func New() Parser

New creates a new YAML parser.

type TypeID

type TypeID string

TypeID represents the value structure in accordance with the YAML specification 10.1.1. See https://yaml.org/spec/1.2.2/#101-failsafe-schema for details.

const (
	// TypeIDMap is a generic map in accordance with the YAML specification 10.1.1.1.
	TypeIDMap TypeID = "map"
	// TypeIDSequence is a generic sequence in accordance with YAML specification 10.1.1.2.
	TypeIDSequence TypeID = "seq"
	// TypeIDString is a generic string in accordance with YAML specification 10.1.1.3.
	TypeIDString TypeID = "str"
)

Jump to

Keyboard shortcuts

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