defaults

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFrom added in v1.18.0

func ReadFrom(path, fallbackPath string, value any) error

ReadFrom reads a configuration file to the value. This function will try to read from given path, if it is empty will try fallback path. If it fails on fallback, it will set value to its defaults

func Set

func Set(value interface{}) error

Set sets the default values to fields

func Validate

func Validate(value interface{}) error

Validate validates each field of the value

Types

type Decoder added in v1.18.0

type Decoder interface {
	Decode(value any) error
	DisallowUnknownFields()
}

type JSONDecoder added in v1.18.0

type JSONDecoder struct {
	*json.Decoder
}

func NewJSONDecoder added in v1.18.0

func NewJSONDecoder(r io.Reader) *JSONDecoder

type TOMLDecoder added in v1.18.0

type TOMLDecoder struct {
	*toml.Decoder
}

func NewTOMLDecoder added in v1.18.0

func NewTOMLDecoder(r io.Reader) *TOMLDecoder

func (*TOMLDecoder) Decode added in v1.18.0

func (d *TOMLDecoder) Decode(value interface{}) error

func (*TOMLDecoder) DisallowUnknownFields added in v1.18.0

func (d *TOMLDecoder) DisallowUnknownFields()

DisallowUnknownFields will disallow unknown fields in the TOML file. Override this method to ensure Decoder interface is met

Jump to

Keyboard shortcuts

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