gyaml

package
v0.0.0-...-3ebf473 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

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.

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) (bool, error)

Bool returns a bool according to a dotted path.

func (*YAML) DBool

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

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

func (*YAML) DFloat64

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

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

func (*YAML) DInt

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

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

func (*YAML) DList

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

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

func (*YAML) DListString

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

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

func (*YAML) DMap

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

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

func (*YAML) DString

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

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

func (*YAML) Data

func (y *YAML) Data() any

func (*YAML) Float64

func (y *YAML) Float64(path string) (float64, error)

Float64 returns a float64 according to a dotted path.

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) (int, error)

Int returns an int according to a dotted path.

func (*YAML) List

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

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

func (*YAML) Map

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

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

func (*YAML) String

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

String returns a string according to a dotted path.

Jump to

Keyboard shortcuts

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