config

package module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 12 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func All

func All() map[string]interface{}

func ConfigName

func ConfigName() string

func Expand

func Expand(s string) string

func ForEach

func ForEach(path string, fn func(c *Config) error) error

func GetBool

func GetBool(path string) bool

func GetDuration

func GetDuration(path string) time.Duration

func GetFloat64

func GetFloat64(path string) float64

func GetFloat64Slice

func GetFloat64Slice(path string) []float64

func GetInt

func GetInt(path string) int

func GetInt64

func GetInt64(path string) int64

func GetInt64Slice

func GetInt64Slice(path string) []int64

func GetIntSlice

func GetIntSlice(path string) []int

func GetInterface

func GetInterface(path string) interface{}

func GetString

func GetString(path string) string

func GetStringMap

func GetStringMap(path string) map[string]string

func GetStringSlice

func GetStringSlice(path string) []string

func GetTime

func GetTime(path string) time.Time

func GetUint

func GetUint(path string) uint

func GetUint64

func GetUint64(path string) uint64

func GetUint64Slice

func GetUint64Slice(path string) []uint64

func GetUintSlice

func GetUintSlice(path string) []uint

func MustReadConfigFile

func MustReadConfigFile() error

func ParseTime

func ParseTime(v string) (time.Time, error)

func ReadConfig

func ReadConfig(buf []byte) error

func ReadConfigFile

func ReadConfigFile() error

func Unmarshal

func Unmarshal(path string, val interface{}) error

Types

type Config

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

func NewConfig

func NewConfig() *Config

func Set

func Set(key string, val interface{}) *Config

func SetConfigName

func SetConfigName(name string) *Config

func SetDefault

func SetDefault(key string, val interface{}) *Config

func SetEnvPrefix

func SetEnvPrefix(p string) *Config

func UseEnv

func UseEnv(enabled bool) *Config

func (*Config) All

func (c *Config) All() map[string]interface{}

func (*Config) ConfigName

func (c *Config) ConfigName() string

func (*Config) EnvPrefix

func (c *Config) EnvPrefix() string

func (*Config) Expand

func (c *Config) Expand(s string) string

Resolves env/config variables embedded in a string using ${VAR}

func (*Config) ForEach

func (c *Config) ForEach(path string, fn func(c *Config) error) error

func (*Config) GetBool

func (c *Config) GetBool(path string) bool

func (*Config) GetDuration

func (c *Config) GetDuration(path string) time.Duration

func (*Config) GetFloat64

func (c *Config) GetFloat64(path string) float64

func (*Config) GetFloat64Slice

func (c *Config) GetFloat64Slice(path string) []float64

func (*Config) GetInt

func (c *Config) GetInt(path string) int

func (*Config) GetInt64

func (c *Config) GetInt64(path string) int64

func (*Config) GetInt64Slice

func (c *Config) GetInt64Slice(path string) []int64

func (*Config) GetIntSlice

func (c *Config) GetIntSlice(path string) []int

func (*Config) GetInterface

func (c *Config) GetInterface(path string) interface{}

func (*Config) GetString

func (c *Config) GetString(path string) string

func (*Config) GetStringMap

func (c *Config) GetStringMap(path string) map[string]string

func (*Config) GetStringSlice

func (c *Config) GetStringSlice(path string) []string

func (*Config) GetTime

func (c *Config) GetTime(path string) time.Time

func (*Config) GetUint

func (c *Config) GetUint(path string) uint

func (*Config) GetUint64

func (c *Config) GetUint64(path string) uint64

func (*Config) GetUint64Slice

func (c *Config) GetUint64Slice(path string) []uint64

func (*Config) GetUintSlice

func (c *Config) GetUintSlice(path string) []uint

func (*Config) MustReadConfigFile

func (c *Config) MustReadConfigFile() error

func (*Config) ReadConfig

func (c *Config) ReadConfig(buf []byte) error

func (*Config) ReadConfigFile

func (c *Config) ReadConfigFile(failNonExist ...bool) error

func (*Config) Set

func (c *Config) Set(key string, val interface{}) *Config

func (*Config) SetConfigName

func (c *Config) SetConfigName(name string) *Config

func (*Config) SetDefault

func (c *Config) SetDefault(key string, val interface{}) *Config

func (*Config) SetEnvPrefix

func (c *Config) SetEnvPrefix(p string) *Config

func (*Config) Unmarshal

func (c *Config) Unmarshal(path string, val interface{}) error

func (*Config) Use

func (c *Config) Use(val map[string]interface{}) *Config

func (*Config) UseEnv

func (c *Config) UseEnv(enabled bool) *Config

type Duration

type Duration time.Duration

func ParseDuration

func ParseDuration(d string) (Duration, error)

func (Duration) Duration

func (d Duration) Duration() time.Duration

Jump to

Keyboard shortcuts

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