configutil

package
v0.31.5 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Duration added in v0.31.2

type Duration time.Duration

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 (d *Duration) MarshalJSON() ([]byte, error)

func (*Duration) MarshalYAML added in v0.31.3

func (d *Duration) MarshalYAML() (any, error)

func (*Duration) UnmarshalJSON added in v0.31.2

func (d *Duration) UnmarshalJSON(data []byte) error

func (*Duration) UnmarshalYAML added in v0.31.3

func (d *Duration) UnmarshalYAML(value *yaml.Node) error

type SetDefault

type SetDefault interface {
	SetDefault(key string, value any)
}

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

type SetDefaultFunc func(key string, value any)

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.

Jump to

Keyboard shortcuts

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