Documentation
¶
Index ¶
- Constants
- 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 Rate
- type SecretString
- type SecretURL
- type Size
- type URL
- type UniqueStrings
- type Validated
Constants ¶
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 flattened 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 Rate ¶ added in v0.8.0
Rate includes a per second limit and a burst. Rates >= 1 are printed as "<rate>rps:<burst>". Rates < 1 are printed as "every<duration>:<burst>".
type SecretString ¶ added in v0.5.0
type SecretString string
SecretString is a string that formats and encodes redacted, as "xxxxx".
func NewSecretString ¶ added in v0.5.0
func NewSecretString(s string) *SecretString
func (SecretString) GoString ¶ added in v0.5.0
func (s SecretString) GoString() string
func (SecretString) MarshalText ¶ added in v0.5.0
func (s SecretString) MarshalText() ([]byte, error)
func (SecretString) String ¶ added in v0.5.0
func (s SecretString) String() string
type SecretURL ¶ added in v0.5.0
type SecretURL URL
SecretURL is a URL that formats and encodes redacted, as "xxxxx".
func MustSecretURL ¶ added in v0.5.0
func NewSecretURL ¶ added in v0.5.0
func (*SecretURL) MarshalText ¶ added in v0.5.0
func (*SecretURL) UnmarshalText ¶ added in v0.5.0
type Size ¶ added in v0.8.0
type Size int
Size represents size in bytes, and formats with a suffix.
func (Size) MarshalText ¶ added in v0.8.0
func (*Size) UnmarshalText ¶ added in v0.8.0
UnmarshalText parses a size from bs in to s.
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.