yamls

package
v0.11.21 Latest Latest
Warning

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

Go to latest
Published: May 14, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Unmarshal = yaml.Unmarshal
	Marshal   = yaml.Marshal

	UnmarshalString = func(buf string, val any) error {
		return Unmarshal(string2Bytes(buf), val)
	}
	MarshalString = func(val any) (string, error) {
		bs, err := Marshal(val)
		if err != nil {
			return "", err
		}

		return bytes2String(bs), err
	}

	NewEncoder = func(w io.Writer) YAMLEncoder {
		return yaml.NewEncoder(w)
	}
	NewDecoder = func(r io.Reader) YAMLDecoder {
		return yaml.NewDecoder(r)
	}

	MustMarshal = func(v any) []byte {
		bs, err := Marshal(v)
		if err != nil {
			panic(err)
		}
		return bs
	}
	MustUnmarshal = func(bs []byte, v any) {
		err := Unmarshal(bs, v)
		if err != nil {
			panic(err)
		}
	}
	MustMarshalString = func(v any) string {
		bs, err := Marshal(v)
		if err != nil {
			panic(err)
		}
		return bytes2String(bs)
	}
	MustUnmarshalString = func(s string, v any) {
		err := Unmarshal(string2Bytes(s), v)
		if err != nil {
			panic(err)
		}
	}
)

Functions

This section is empty.

Types

type YAMLDecoder

type YAMLDecoder interface {
	Decode(any) error
}

type YAMLEncoder

type YAMLEncoder interface {
	Encode(any) error
}

Jump to

Keyboard shortcuts

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