yaml

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: Apache-2.0 Imports: 6 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(src any, path string) (any, error)

Get returns a child of the given value according to a dotted path. The source data must be either map[string]any or []any

func GetBool

func GetBool(data any, path string, defaults ...bool) bool

Bool returns a bool according to a dotted path or default value or false.

func GetFloat64

func GetFloat64(data any, path string, defaults ...float64) float64

Float64 returns a float64 according to a dotted path or default value or 0.

func GetInt

func GetInt(data any, path string, defaults ...int) int

Int returns an int according to a dotted path or default value or 0.

func GetList

func GetList(data any, path string, defaults ...[]any) []any

List returns a []any according to a dotted path or defaults or []any.

func GetListString

func GetListString(data any, path string, defaults ...[]string) []string

ListString is for the very common case of a list of strings

func GetMap

func GetMap(data any, path string, defaults ...map[string]any) map[string]any

Map returns a map[string]any according to a dotted path or default or map[string]any.

func GetString

func GetString(data any, path string, defaults ...string) string

String returns a string according to a dotted path or default or "".

func ToListString

func ToListString(in []any) []string

Types

type YAML

type YAML struct {
	// contains filtered or unexported fields
}

YAML represents a complex internal YAML structure with convenient access methods, using dotted path syntax

func New

func New(data any) *YAML

func ParseJson

func ParseJson(src string) (*YAML, error)

ParseJson reads a JSON configuration from the given string.

func ParseJsonFile

func ParseJsonFile(filename string) (*YAML, error)

ParseJsonFile reads a JSON configuration from the given filename.

func ParseYaml

func ParseYaml(src string) (*YAML, error)

ParseYaml reads a YAML configuration from the given string.

func ParseYamlBytes

func ParseYamlBytes(src []byte) (*YAML, error)

ParseYamlBytes reads a YAML configuration from the given []byte.

func ParseYamlFile

func ParseYamlFile(filename string) (*YAML, error)

ParseYamlFile reads a YAML configuration from the given filename.

func (*YAML) Bool

func (y *YAML) Bool(path string, defaults ...bool) bool

Bool returns a bool according to a dotted path or default value or false.

func (*YAML) Data

func (y *YAML) Data() any

func (*YAML) Float64

func (y *YAML) Float64(path string, defaults ...float64) float64

Float64 returns a float64 according to a dotted path or default value or 0.

func (*YAML) Get

func (y *YAML) Get(path string) (*YAML, error)

Get returns a nested element according to a dotted path.

func (*YAML) Int

func (y *YAML) Int(path string, defaults ...int) int

Int returns an int according to a dotted path or default value or 0.

func (*YAML) List

func (y *YAML) List(path string, defaults ...[]any) []any

List returns a []any according to a dotted path or defaults or []any.

func (*YAML) ListString

func (y *YAML) ListString(path string, defaults ...[]string) []string

ListString is for the very common case of a list of strings

func (*YAML) Map

func (y *YAML) Map(path string, defaults ...map[string]any) map[string]any

Map returns a map[string]any according to a dotted path or default or map[string]any.

func (*YAML) String

func (y *YAML) String(path string, defaults ...string) string

String returns a string according to a dotted path or default or "".

Jump to

Keyboard shortcuts

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