config

package
v0.0.0-...-e3aa4fd Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultConfigName default config name for viper
	DefaultConfigName = "default"
)

Functions

func Get

func Get(key string, configName ...string) (value interface{})

Get get configuration value from an instance type interface

func GetBool

func GetBool(key string, configName ...string) (value bool)

GetBool get configuration value from an instance type bool

func GetDuration

func GetDuration(key string, configName ...string) (value time.Duration)

GetDuration get configuration value from an instance type time.Duration

func GetFloat64

func GetFloat64(key string, configName ...string) (value float64)

GetFloat64 get configuration value from an instance type float64

func GetInt

func GetInt(key string, configName ...string) (value int)

GetInt get configuration value from an instance type int

func GetInt64

func GetInt64(key string, configName ...string) (value int64)

GetInt64 get configuration value from an instance type int64

func GetString

func GetString(key string, configName ...string) (value string)

GetString get configuration value from an instance type string

func GetStringMapString

func GetStringMapString(key string, configName ...string) (value map[string][]string)

GetStringMapString get configuration value from an instance type map string of string

func GetStringSlice

func GetStringSlice(key string, configName ...string) (value []string)

GetStringSlice get configuration value from an instance type slice of string

func GetTime

func GetTime(key string, configName ...string) (value time.Time)

GetTime get configuration value from an instance type time.Time

func NewConfigFromFile

func NewConfigFromFile(configName, configType, filePath string, options NewConfigOptions) (err error)

NewConfigFromFile instantiate new configuration instance Config in this example is read-only, you can't set it on the fly so don't return any possible interface to do so

func NewConfigFromString

func NewConfigFromString(configName, value string, options NewConfigOptions) (err error)

NewConfigFromString instantiate new configuration instance using string, useful for testing

func UnmarshalKey

func UnmarshalKey(key string, rawVal interface{}, configName ...string) (err error)

UnmarshalKey takes a single key and unmarshals it into a Struct.

Types

type NewConfigOptions

type NewConfigOptions struct {
	// DefaultName used for default config name that will be used
	DefaultName string

	// Defaults used for default value for each config
	Defaults map[string]interface{}
	IsWatch  bool
}

NewConfigOptions options for initializing new config instance

Jump to

Keyboard shortcuts

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