Documentation ¶
Index ¶
- Variables
- func Bool(key string, def ...interface{}) (bool, error)
- func Float(key string, def ...interface{}) (float64, error)
- func Get(key string, def ...interface{}) (interface{}, error)
- func Int(key string, def ...interface{}) (int64, error)
- func List(key string, def ...interface{}) ([]string, error)
- func MustBool(key string, def ...interface{}) bool
- func MustFloat(key string, def ...interface{}) float64
- func MustGet(key string, def ...interface{}) interface{}
- func MustInt(key string, def ...interface{}) int64
- func MustList(key string, def ...interface{}) []string
- func MustString(key string, def ...interface{}) string
- func MustUint(key string, def ...interface{}) uint64
- func ReadAndWatchFile(path string)
- func RegisterFileType(ext string, callback fileCallback)
- func Reset()
- func String(key string, def ...interface{}) (string, error)
- func Uint(key string, def ...interface{}) (uint64, error)
- func Use(middleware ...Middleware)
- func WatchFile(path string)
- type Config
- type Env
- func (s *Env) Bool(key string) (bool, error)
- func (s *Env) Float(key string) (float64, error)
- func (s *Env) Get(key string) (interface{}, error)
- func (s *Env) ID() string
- func (s *Env) Int(key string) (int64, error)
- func (s *Env) List(key string) ([]string, error)
- func (s *Env) Setup() error
- func (s *Env) String(key string) (string, error)
- func (s *Env) Uint(key string) (uint64, error)
- type File
- func (s *File) Bool(key string) (bool, error)
- func (s *File) Float(key string) (float64, error)
- func (s *File) Get(key string) (interface{}, error)
- func (s *File) ID() string
- func (s *File) Int(key string) (int64, error)
- func (s *File) List(key string) ([]string, error)
- func (s *File) Setup() error
- func (s *File) String(key string) (string, error)
- func (s *File) Uint(key string) (uint64, error)
- type Middleware
- type Values
- func (s *Values) Bool(key string) (bool, error)
- func (s *Values) Float(key string) (float64, error)
- func (s *Values) Get(key string) (interface{}, error)
- func (s *Values) ID() string
- func (s *Values) Int(key string) (int64, error)
- func (s *Values) List(key string) ([]string, error)
- func (s *Values) Setup() error
- func (s *Values) String(key string) (string, error)
- func (s *Values) Uint(key string) (uint64, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoValueFound it's the error when no value is found. ErrNoValueFound = errors.New("Value not found for the given key") )
Functions ¶
func MustFloat ¶
MustFloat returns a float64 from the config file, it will panic if a error is created.
func MustGet ¶ added in v1.1.0
func MustGet(key string, def ...interface{}) interface{}
MustGet returns a interface from the config file, it will panic if a error is created.
func MustList ¶
MustList returns a slice of strings from the config file, it will panic if a error is created.
func MustString ¶
MustString returns a string from the config file, it will panic if a error is created.
func MustUint ¶
MustUint returns a unsigned int64 from the config file, it will panic if a error is created.
func ReadAndWatchFile ¶
func ReadAndWatchFile(path string)
ReadAndWatchFile reads and watches file for changes and reload the configuration file.
func RegisterFileType ¶
func RegisterFileType(ext string, callback fileCallback)
RegisterFileType register a file type with a callback.
Types ¶
type Config ¶
Config is the struct for the config.
func (*Config) Data ¶
func (c *Config) Data() map[interface{}]interface{}
Data returns all config values.
func (*Config) Get ¶
func (c *Config) Get(key interface{}) interface{}
Get returns a config value by key or nil.
func (*Config) Middlewares ¶
func (c *Config) Middlewares() []Middleware
Middlewares returns a existing middlewares.
type Env ¶
type Env struct { }
Env middleware struct that handles environment variables.
type File ¶
type File struct {
// contains filtered or unexported fields
}
File struct is a config file.
type Middleware ¶
type Middleware interface { ID() string Bool(name string) (bool, error) Float(name string) (float64, error) Int(name string) (int64, error) Get(name string) (interface{}, error) List(name string) ([]string, error) Setup() error String(name string) (string, error) Uint(name string) (uint64, error) }
Middleware is the interface that external middlewares must implement.
func NewFromBytes ¶
func NewFromBytes(typ string, body []byte) Middleware
NewFromBytes creates a new middleware from bytes as the given type, e.g: json.
func NewFromFile ¶
func NewFromFile(path string, watch ...bool) Middleware
NewFromFile creates a new middleware from file. Optional bool argument to watch file.
type Values ¶
type Values struct {
// contains filtered or unexported fields
}
Values middleware struct that handles predefined values.
func NewFromValues ¶
NewFromValues creates a new values middleware.