config

package
v2.5.1-clf-20230912 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeTOML

func DecodeTOML(r io.Reader, v any) error

DecodeTOML decodes toml from r in to v. Requires strict field matches and returns full toml.StrictMissingError details.

func NamedMultiErrorList

func NamedMultiErrorList(err error, name string) error

func Validate

func Validate(cfg interface{}) (err error)

Validate returns any errors from calling Validated.ValidateConfig on cfg and any nested types that implement Validated.

Types

type ErrEmpty

type ErrEmpty struct {
	Name string
	Msg  string
}

func (ErrEmpty) Error

func (e ErrEmpty) Error() string

type ErrInvalid

type ErrInvalid struct {
	Name  string
	Value any
	Msg   string
}

func NewErrDuplicate

func NewErrDuplicate(name string, value any) ErrInvalid

NewErrDuplicate returns an ErrInvalid with a standard duplicate message.

func (ErrInvalid) Error

func (e ErrInvalid) Error() string

type ErrMissing

type ErrMissing struct {
	Name string
	Msg  string
}

func (ErrMissing) Error

func (e ErrMissing) Error() string

type ErrOverride

type ErrOverride struct {
	Name string
}

func (ErrOverride) Error

func (e ErrOverride) Error() string

type UniqueStrings

type UniqueStrings map[string]struct{}

UniqueStrings is a helper for tracking unique values in string form.

func (UniqueStrings) IsDupe

func (u UniqueStrings) IsDupe(s *string) bool

IsDupe returns true if the set already contains the string, otherwise false. Non-nil/empty strings are added to the set.

func (UniqueStrings) IsDupeFmt

func (u UniqueStrings) IsDupeFmt(t fmt.Stringer) bool

IsDupeFmt is like IsDupe, but calls String().

type Validated

type Validated interface {
	// ValidateConfig returns nil if the config is valid, otherwise an error describing why it is invalid.
	//
	// For implementations:
	//  - Use package multierr to accumulate all errors, rather than returning the first encountered.
	//  - If an anonymous field also implements ValidateConfig(), it must be called explicitly!
	ValidateConfig() error
}

Validated configurations impose constraints that must be checked.

Jump to

Keyboard shortcuts

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