Documentation ¶
Index ¶
- func DecodeTOML(r io.Reader, v any) error
- func Flatten(errs ...error) (flat []error)
- func MultiErrorList(err error) (int, error)
- func NamedMultiErrorList(err error, name string) error
- func Validate(cfg interface{}) (err error)
- type Duration
- func (d Duration) Before(t time.Time) time.Time
- func (d Duration) Duration() time.Duration
- func (d Duration) IsInstant() bool
- func (d Duration) MarshalJSON() ([]byte, error)
- func (d Duration) MarshalText() ([]byte, error)
- func (d *Duration) Scan(v interface{}) (err error)
- func (d Duration) Shorter(od Duration) bool
- func (d Duration) String() string
- func (d *Duration) UnmarshalJSON(input []byte) error
- func (d *Duration) UnmarshalText(input []byte) error
- func (d Duration) Value() (driver.Value, error)
- type ErrEmpty
- type ErrInvalid
- type ErrMissing
- type KeyNotFoundError
- type URL
- type UniqueStrings
- type Validated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeTOML ¶
DecodeTOML decodes toml from r in to v. Requires strict field matches and returns full toml.StrictMissingError details.
func Flatten ¶
Flatten calls `Unwrap() []error` on each error and subsequent returned error that implement the method, returning a fully flattend sequence.
func MultiErrorList ¶
MultiErrorList returns an error which formats underlying errors as a list, or nil if err is nil.
func NamedMultiErrorList ¶
Types ¶
type Duration ¶
type Duration struct {
// contains filtered or unexported fields
}
Duration is a non-negative time duration.
func MustNewDuration ¶
func ParseDuration ¶
func (Duration) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (Duration) MarshalText ¶
MarshalText implements the text.Marshaler interface.
func (Duration) String ¶
String returns a string representing the duration in the form "72h3m0.5s". Leading zero units are omitted. As a special case, durations less than one second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure that the leading digit is non-zero. The zero duration formats as 0s.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
func (*Duration) UnmarshalText ¶
UnmarshalText implements the text.Unmarshaler interface.
type ErrInvalid ¶
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 ¶
func (ErrMissing) Error ¶
func (e ErrMissing) Error() string
type KeyNotFoundError ¶
func (KeyNotFoundError) Error ¶
func (e KeyNotFoundError) Error() string
type URL ¶
URL extends url.URL to implement encoding.TextMarshaler.
func MustParseURL ¶
func (*URL) MarshalText ¶
func (*URL) UnmarshalText ¶
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.
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.