Documentation
¶
Overview ¶
Configuration loader
Index ¶
- Constants
- func CheckKeyIsExists(key string) bool
- func GetBoolOrDefault(key string, or bool) bool
- func GetFloat32OrDefault(key string, or float32) float32
- func GetFloat64OrDefault(key string, or float64) float64
- func GetInt64OrDefault(key string, or int64) int64
- func GetIntOrDefault(key string, or int) int
- func GetStringOrDefault(key, or string) string
- func GetStringSliceOrDefault(key string, or []string) []string
- func LoadConfig(options ...Option) (err error)
- func SetConfig(key string, value interface{}) error
- type KeyBuilder
- func (ckb *KeyBuilder) CheckKeyIsExists(key string) bool
- func (ckb *KeyBuilder) Clone() *KeyBuilder
- func (ckb *KeyBuilder) Current() string
- func (ckb *KeyBuilder) GetBoolOrDefault(key string, or bool) bool
- func (ckb *KeyBuilder) GetFloat32OrDefault(key string, or float32) float32
- func (ckb *KeyBuilder) GetFloat64OrDefault(key string, or float64) float64
- func (ckb *KeyBuilder) GetInt64OrDefault(key string, or int64) int64
- func (ckb *KeyBuilder) GetIntOrDefault(key string, or int) int
- func (ckb *KeyBuilder) GetKey(key string) string
- func (ckb *KeyBuilder) GetStringOrDefault(key string, or string) string
- func (ckb *KeyBuilder) GetStringSliceOrDefault(key string, or []string) []string
- func (ckb *KeyBuilder) Join(elems ...string) string
- func (ckb *KeyBuilder) SubViper(key string) *viper.Viper
- func (ckb *KeyBuilder) WithClass(c string) *KeyBuilder
- func (ckb *KeyBuilder) WithProfile(p string) *KeyBuilder
- type MongoAuth
- type MongoConfig
- type Option
- type RedisConfig
- type SMTPConfig
- type SMTPConfigOption
Constants ¶
View Source
const ( KeyDefaultProfile = "default" KeyRedisBase = "redis" KeyRedisHost = "host" KeyRedisPort = "port" KeyRedisPass = "pass" KeyRedisDb = "db" KeyMongoBase = "mongo" KeyMongoAddrs = "addrs" KeyMongoPerformAuth = "with_auth" KeyMongoAuthBase = "auth" KeyMongoAuthDatabase = "db" KeyMongoAuthUser = "user" KeyMongoAuthPass = "pass" KeyMongoAuthMechanism = "mechanism" KeyMongoTimeoutSec = "timeout_sec" KeyMongoDatabase = "db" KeyMailBase = "mail" KeyMailSMTPBase = "smtp" KeyMailSMTPHost = "host" KeyMailSMTPPort = "port" KeyMailSMTPSender = "sender" KeyMailSMTPUser = "user" KeyMailSMTPPass = "pass" KeyMailSMTPOption = "option" KeyMailSMTPOptionInsecureSkipVerify = "insecure_skip_verify" )
Variables ¶
This section is empty.
Functions ¶
func CheckKeyIsExists ¶
func GetBoolOrDefault ¶
func GetFloat32OrDefault ¶
func GetFloat64OrDefault ¶
func GetInt64OrDefault ¶
func GetIntOrDefault ¶
func GetStringOrDefault ¶
func GetStringSliceOrDefault ¶
func LoadConfig ¶
this function will search and load configurations
Types ¶
type KeyBuilder ¶
func NewKeyBuilder ¶
func NewKeyBuilder(base string, rest ...string) (ckb *KeyBuilder)
func (*KeyBuilder) CheckKeyIsExists ¶
func (ckb *KeyBuilder) CheckKeyIsExists(key string) bool
func (*KeyBuilder) Clone ¶
func (ckb *KeyBuilder) Clone() *KeyBuilder
func (*KeyBuilder) Current ¶
func (ckb *KeyBuilder) Current() string
func (*KeyBuilder) GetBoolOrDefault ¶
func (ckb *KeyBuilder) GetBoolOrDefault(key string, or bool) bool
func (*KeyBuilder) GetFloat32OrDefault ¶
func (ckb *KeyBuilder) GetFloat32OrDefault(key string, or float32) float32
func (*KeyBuilder) GetFloat64OrDefault ¶
func (ckb *KeyBuilder) GetFloat64OrDefault(key string, or float64) float64
func (*KeyBuilder) GetInt64OrDefault ¶
func (ckb *KeyBuilder) GetInt64OrDefault(key string, or int64) int64
func (*KeyBuilder) GetIntOrDefault ¶
func (ckb *KeyBuilder) GetIntOrDefault(key string, or int) int
func (*KeyBuilder) GetKey ¶
func (ckb *KeyBuilder) GetKey(key string) string
func (*KeyBuilder) GetStringOrDefault ¶
func (ckb *KeyBuilder) GetStringOrDefault(key string, or string) string
func (*KeyBuilder) GetStringSliceOrDefault ¶
func (ckb *KeyBuilder) GetStringSliceOrDefault(key string, or []string) []string
func (*KeyBuilder) Join ¶
func (ckb *KeyBuilder) Join(elems ...string) string
func (*KeyBuilder) WithClass ¶
func (ckb *KeyBuilder) WithClass(c string) *KeyBuilder
func (*KeyBuilder) WithProfile ¶
func (ckb *KeyBuilder) WithProfile(p string) *KeyBuilder
type MongoAuth ¶
*
- Database is the default database name used when the Session.DB method
- is called with an empty name, and is also used during the initial
- authentication if Source is unset. *
- Username and Password inform the credentials for the initial authentication
- done on the database defined by the Source field. See Session.Login. *
func GetDBMongoAuth ¶
func GetDBMongoAuth(ckb *KeyBuilder) *MongoAuth
type MongoConfig ¶
func LoadMongoConfig ¶
func LoadMongoConfig(profile string) (cfg *MongoConfig)
type Option ¶
type Option struct { Project string Path string FileMustExists bool DefaultPath string DefaultConfigureName string ConfigSearchPath string ConfigSearchPaths []string ConfigFallbackSearchPath string }
func (*Option) GetDefaultPath ¶
type RedisConfig ¶
func LoadRedisConfig ¶
func LoadRedisConfig(profile string) *RedisConfig
Example Config File:
redis: default: # profile host: 127.0.0.1 port: 6379 pass: "" # empty for not encrypted db: 0 # db number
type SMTPConfig ¶
type SMTPConfig struct { Host string `mapstructure:"host"` Port int `mapstructure:"port"` Sender string `mapstructure:"sender"` User string `mapstructure:"user"` Pass string `mapstructure:"pass"` // SkipTLS Option SMTPConfigOption `mapstructure:"option"` }
func LoadSMTPConfig ¶
func LoadSMTPConfig(profile string) (cfg *SMTPConfig, err error)
Example Config File:
mail: # base-0 smtp: # base-1 default: # profile host: 127.0.0.1 port: 25 sender: Alice Ez user: "[email protected]" pass: "your-password" # empty for no authorization option: insecure_skip_verify: true nightly: # profile host: 127.0.0.1 port: 25 sender: Alice Ez user: "[email protected]" pass: "your-password" # empty for no authorization option: insecure_skip_verify: true
type SMTPConfigOption ¶
type SMTPConfigOption struct {
InsecureSkipVerify bool `mapstructure:"insecure_skip_verify"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.