Documentation ¶
Overview ¶
Package config manages configurations of application.
Package config manages configurations of application.
Index ¶
- func AddDataSource(data []byte, ct string)
- func AddFileSource(path string)
- func AddFolder(dirs ...string)
- func AddSource(srcs ...Source)
- func BindEnv(key string, envKey string)
- func BindFlags(set *flag.FlagSet)
- func Exist(key string) bool
- func FindFile(name string, exts ...string) string
- func FindFiles(name string, exts ...string) []string
- func FindFolder(name string) string
- func FindFolders(name string) []string
- func Get(key string) interface{}
- func GetBool(key string) bool
- func GetDuration(key string) time.Duration
- func GetInt(key string) int
- func GetInt16(key string) int16
- func GetInt32(key string) int32
- func GetInt64(key string) int64
- func GetInt8(key string) int8
- func GetString(key string) string
- func GetTime(key string) time.Time
- func GetUint(key string) uint
- func GetUint16(key string) uint16
- func GetUint32(key string) uint32
- func GetUint64(key string) uint64
- func GetUint8(key string) uint8
- func Load() error
- func SetDefaultValue(name string, value interface{})
- func SetEnvPrefix(prefix string)
- func SetName(name string)
- func SetProfile(profiles ...string)
- func Unmarshal(v interface{}) error
- func UnmarshalOption(name string, v interface{}) error
- type Manager
- func (m *Manager) AddDataSource(data []byte, ct string)
- func (m *Manager) AddFileSource(path string)
- func (m *Manager) AddFolder(dirs ...string)
- func (m *Manager) AddSource(srcs ...Source)
- func (m *Manager) BindEnv(key string, envKey string)
- func (m *Manager) BindFlags(set *flag.FlagSet)
- func (m *Manager) FindFile(name string, exts ...string) string
- func (m *Manager) FindFiles(name string, exts ...string) []string
- func (m *Manager) FindFolder(name string) string
- func (m *Manager) FindFolders(name string) []string
- func (m *Manager) Get(key string) interface{}
- func (m *Manager) GetBool(key string) bool
- func (m *Manager) GetDuration(key string) time.Duration
- func (m *Manager) GetInt(key string) int
- func (m *Manager) GetInt16(key string) int16
- func (m *Manager) GetInt32(key string) int32
- func (m *Manager) GetInt64(key string) int64
- func (m *Manager) GetInt8(key string) int8
- func (m *Manager) GetString(key string) string
- func (m *Manager) GetTime(key string) time.Time
- func (m *Manager) GetUint(key string) uint
- func (m *Manager) GetUint16(key string) uint16
- func (m *Manager) GetUint32(key string) uint32
- func (m *Manager) GetUint64(key string) uint64
- func (m *Manager) GetUint8(key string) uint8
- func (m *Manager) Load() error
- func (m *Manager) SetDefaultValue(name string, value interface{})
- func (m *Manager) SetEnvPrefix(prefix string)
- func (m *Manager) SetName(name string)
- func (m *Manager) SetProfile(profiles ...string)
- func (m *Manager) Unmarshal(v interface{}) error
- func (m *Manager) UnmarshalOption(name string, v interface{}) error
- type Source
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDataSource ¶
AddDataSource add a config source with bytes and type.
func AddFileSource ¶
func AddFileSource(path string)
AddFileSource adds a file configuration source.
func FindFolder ¶
FindFolder searches all config directories and return the first found folder.
func FindFolders ¶
FindFolders searches all config directories and return all found folders.
func Get ¶
func Get(key string) interface{}
Get searches option from flag/env/config/remote/default. It returns nil if option is not found.
func GetDuration ¶
GetDuration returns option as time.Duration.
func SetDefaultValue ¶
func SetDefaultValue(name string, value interface{})
SetDefaultValue sets a default option.
func SetEnvPrefix ¶
func SetEnvPrefix(prefix string)
SetEnvPrefix sets the prefix of environment variables. Default prefix is "AUXO".
func SetName ¶
func SetName(name string)
SetName sets name of the main configuration file (without extension).
func SetProfile ¶
func SetProfile(profiles ...string)
SetProfile sets active profiles. Profiles are only valid to local file sources.
func UnmarshalOption ¶
UnmarshalOption exports specific option to struct.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) AddDataSource ¶
AddDataSource add a config source with bytes and type.
func (*Manager) AddFileSource ¶
AddFileSource adds a file configuration source.
func (*Manager) FindFile ¶
FindFile searches all config directories and return the first found file.
func (*Manager) FindFolder ¶
FindFolder searches all config directories and return the first found folder.
func (*Manager) FindFolders ¶
FindFolders searches all config directories and return all found folders.
func (*Manager) Get ¶
Get searches option from flag/env/config/remote/default. It returns nil if option is not found.
func (*Manager) GetDuration ¶
GetDuration returns option as time.Duration.
func (*Manager) SetDefaultValue ¶
SetDefaultValue sets a default option.
func (*Manager) SetEnvPrefix ¶
SetEnvPrefix sets the prefix of environment variables. Default prefix is "AUXO".
func (*Manager) SetProfile ¶
SetProfile sets active profiles. Profiles are only valid to local file sources.
func (*Manager) UnmarshalOption ¶
UnmarshalOption exports specific option to struct.
type Unmarshaler ¶
type Unmarshaler interface {
Unmarshal(i interface{}) error
}
Unmarshaler is custom unmarshal interface for Config.Unmarshal method.