settings

package
v0.21.26 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KeyDelimiter   = viper.KeyDelimiter
	EnvKeyReplacer = viper.EnvKeyReplacer
)
View Source
var Init = fx.Options(
	fx.Provide(
		New,
	),
)

Functions

This section is empty.

Types

type Option

type Option = viper.Option

type Settings

type Settings struct {
	// contains filtered or unexported fields
}

Settings is a prioritized configuration registry. It maintains a set of configuration sources, fetches values to populate those, and provides them according to the source's priority. The priority of the sources is the following: 1. overrides 2. flags 3. env. variables 4. config file 5. key/value store 6. defaults

func New

func New() Settings

func (*Settings) AddConfigPath

func (s *Settings) AddConfigPath(path string)

AddConfigPath adds a path for Viper to search for the config file in. Can be called multiple times to define multiple search paths.

func (*Settings) AllKeys

func (s *Settings) AllKeys() []string

func (*Settings) AllSettings

func (s *Settings) AllSettings() map[string]any

func (*Settings) AutomaticEnv

func (s *Settings) AutomaticEnv()

AutomaticEnv makes Settings check if environment variables match any of the existing keys (config, default or flags). If matching env vars are found, they are loaded into Viper.

func (*Settings) Get

func (s *Settings) Get(key string) any

func (*Settings) GetBool

func (s *Settings) GetBool(key string) bool

func (*Settings) GetDuration

func (s *Settings) GetDuration(key string) time.Duration

func (*Settings) GetFloat64

func (s *Settings) GetFloat64(key string) float64

func (*Settings) GetInt

func (s *Settings) GetInt(key string) int

func (*Settings) GetInt32

func (s *Settings) GetInt32(key string) int32

func (*Settings) GetInt64

func (s *Settings) GetInt64(key string) int64

func (*Settings) GetString

func (s *Settings) GetString(key string) string

func (*Settings) GetStringMap

func (s *Settings) GetStringMap(key string) map[string]any

func (*Settings) GetStringMapString

func (s *Settings) GetStringMapString(key string) map[string]string

func (*Settings) GetStringMapStringSlice

func (s *Settings) GetStringMapStringSlice(key string) map[string][]string

func (*Settings) GetStringSlice

func (s *Settings) GetStringSlice(key string) []string

func (*Settings) GetTime

func (s *Settings) GetTime(key string) time.Time

func (*Settings) GetUint

func (s *Settings) GetUint(key string) uint

func (*Settings) GetUint32

func (s *Settings) GetUint32(key string) uint32

func (*Settings) GetUint64

func (s *Settings) GetUint64(key string) uint64

func (*Settings) ReadInConfig

func (s *Settings) ReadInConfig() error

ReadInConfig will discover and load the configuration file from disk and key/value stores, searching in one of the defined paths.

func (*Settings) Set

func (s *Settings) Set(key string, value any)

func (*Settings) SetConfigName

func (s *Settings) SetConfigName(name string)

SetConfigName sets name for the config file. Does not include extension.

func (*Settings) SetDefault

func (s *Settings) SetDefault(key string, value any)

func (*Settings) SetFromFile

func (s *Settings) SetFromFile(configFileName string, configSearchPaths ...string) error

func (*Settings) Unmarshal

func (s *Settings) Unmarshal(v any) error

func (*Settings) WatchConfig

func (s *Settings) WatchConfig()

WatchConfig starts watching a config file for changes.

func (*Settings) WriteConfig

func (s *Settings) WriteConfig(filename string) error

WriteConfig writes the current configuration to a given filename.

type StringReplacer

type StringReplacer = viper.StringReplacer

Jump to

Keyboard shortcuts

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