Documentation ¶
Index ¶
- type Duration
- type SetDefault
- type SetDefaultFunc
- type SingleOrMulti
- func (a SingleOrMulti[T]) Copy() SingleOrMulti[T]
- func (a SingleOrMulti[T]) IsMulti() bool
- func (a SingleOrMulti[T]) MarshalJSON() ([]byte, error)
- func (a SingleOrMulti[T]) MarshalYAML() (any, error)
- func (a SingleOrMulti[T]) Multi() []T
- func (a SingleOrMulti[T]) Random() T
- func (a SingleOrMulti[T]) Single() T
- func (a SingleOrMulti[T]) String() string
- func (a *SingleOrMulti[T]) UnmarshalJSON(bytes []byte) error
- func (a *SingleOrMulti[T]) UnmarshalYAML(value *yaml.Node) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Duration ¶ added in v0.31.2
Duration is a configuration duration. It is a wrapper around time.Duration that implements the json.Marshaler and json.Unmarshaler interfaces.
- string is parsed using time.ParseDuration.
- int64 and float64 are interpreted as seconds.
func (*Duration) MarshalJSON ¶ added in v0.31.2
func (*Duration) MarshalYAML ¶ added in v0.31.3
func (*Duration) UnmarshalJSON ¶ added in v0.31.2
func (*Duration) UnmarshalYAML ¶ added in v0.31.3
type SetDefault ¶
SetDefault is an interface to abstract setting Viper defaults. (e.g. Allows adding a key prefix to every call to SetDefault when used with SetDefaultFunc.)
type SetDefaultFunc ¶
SetDefaultFunc implements SetDefault.
func (SetDefaultFunc) SetDefault ¶
func (f SetDefaultFunc) SetDefault(key string, value any)
See SetDefault interface.
type SingleOrMulti ¶ added in v0.24.0
type SingleOrMulti[T any] []T
SingleOrMulti is a type that can be either a single value or a slice of values.
func (SingleOrMulti[T]) Copy ¶ added in v0.31.0
func (a SingleOrMulti[T]) Copy() SingleOrMulti[T]
Copy returns a copy of the SingleOrMulti.
func (SingleOrMulti[T]) IsMulti ¶ added in v0.24.0
func (a SingleOrMulti[T]) IsMulti() bool
IsMulti returns true if the value is a slice of values.
func (SingleOrMulti[T]) MarshalJSON ¶ added in v0.24.0
func (a SingleOrMulti[T]) MarshalJSON() ([]byte, error)
MarshalJSON marshals the value as a JSON array if it is a slice of values. Otherwise, it marshals the single value.
func (SingleOrMulti[T]) MarshalYAML ¶ added in v0.24.0
func (a SingleOrMulti[T]) MarshalYAML() (any, error)
MarshalYAML marshals the value as a YAML array if it is a slice of values. Otherwise, it marshals the single value.
func (SingleOrMulti[T]) Multi ¶ added in v0.24.0
func (a SingleOrMulti[T]) Multi() []T
Multi returns the slice of values.
func (SingleOrMulti[T]) Random ¶ added in v0.24.0
func (a SingleOrMulti[T]) Random() T
Random returns a random value from the slice or zero value if the slice is empty.
func (SingleOrMulti[T]) Single ¶ added in v0.24.0
func (a SingleOrMulti[T]) Single() T
Single returns first value in the slice or zero value if the slice is empty.
func (SingleOrMulti[T]) String ¶ added in v0.24.0
func (a SingleOrMulti[T]) String() string
String returns the string representation of the SingleOrMulti.
func (*SingleOrMulti[T]) UnmarshalJSON ¶ added in v0.24.0
func (a *SingleOrMulti[T]) UnmarshalJSON(bytes []byte) error
UnmarshalJSON unmarshals the value as a JSON array if it is a slice of values. Otherwise, it unmarshals the single value.
func (*SingleOrMulti[T]) UnmarshalYAML ¶ added in v0.24.0
func (a *SingleOrMulti[T]) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML unmarshals the value as a YAML array if it is a slice of values. Otherwise, it unmarshals the single value.