Documentation ¶
Index ¶
- func Bool(key string) bool
- func DateOnly(key string, def ...time.Time) time.Time
- func DateTime(key string, def ...time.Time) time.Time
- func Duration(key string, def ...time.Duration) time.Duration
- func Float(key string, def ...float64) float64
- func Get(key string) any
- func Int(key string, def ...int) int
- func JsonUnmarshal(content []byte) (map[string]interface{}, error)
- func Load() error
- func LoadDotEnv() error
- func LoadEnviron(environ []string)
- func LoadFiles() error
- func LoadObject(config O)
- func LoadOsArgs(args []string)
- func LoadOsEnv()
- func LoadProfiles() error
- func Merge(src *Env)
- func SetFileExt(ext string, fn UnmarshalFn)
- func SetFilePaths(filePaths ...string)
- func SetFileSystem(fs FileSystem)
- func SetLogger(logger Logger)
- func SetProfileKey(profileKey string)
- func SetString(key string, value string)
- func String(key string, def ...string) string
- func Strings(key string, def ...[]string) []string
- func Time(key string, def ...time.Time) time.Time
- func TimeLayout(key string, layout string, def ...time.Time) time.Time
- func TimeOnly(key string, def ...time.Time) time.Time
- type DefaultConfigFn
- type Entry
- type EntryKind
- type Env
- func (c *Env) Bool(key string) bool
- func (c *Env) Clone() *Env
- func (c *Env) DateOnly(key string, def ...time.Time) time.Time
- func (c *Env) DateTime(key string, def ...time.Time) time.Time
- func (c *Env) Duration(key string, def ...time.Duration) time.Duration
- func (c *Env) Float(key string, def ...float64) float64
- func (c *Env) Get(key string) any
- func (c *Env) Int(key string, def ...int) int
- func (c *Env) Keys(key string) []string
- func (c *Env) Load() error
- func (c *Env) LoadDotEnv() error
- func (c *Env) LoadEnviron(environ []string)
- func (c *Env) LoadFiles() error
- func (c *Env) LoadObject(config O)
- func (c *Env) LoadOsArgs(args []string)
- func (c *Env) LoadOsEnv()
- func (c *Env) LoadProfiles() error
- func (c *Env) Merge(src *Env)
- func (c *Env) Set(key string, value any)
- func (c *Env) SetFileExt(ext string, fn UnmarshalFn)
- func (c *Env) SetFilePaths(filePaths ...string)
- func (c *Env) SetFileSystem(fs FileSystem)
- func (c *Env) SetLogger(logger Logger)
- func (c *Env) SetProfileKey(profileKey string)
- func (c *Env) String(key string, def ...string) string
- func (c *Env) Strings(key string, def ...[]string) []string
- func (c *Env) Time(key string, def ...time.Time) time.Time
- func (c *Env) TimeLayout(key string, layout string, def ...time.Time) time.Time
- func (c *Env) TimeOnly(key string, def ...time.Time) time.Time
- type FileSystem
- type Logger
- type O
- type UnmarshalFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JsonUnmarshal ¶
func LoadDotEnv ¶
func LoadDotEnv() error
func LoadEnviron ¶
func LoadEnviron(environ []string)
func LoadObject ¶
func LoadObject(config O)
func LoadOsArgs ¶
func LoadOsArgs(args []string)
func LoadProfiles ¶
func LoadProfiles() error
func SetFileExt ¶
func SetFileExt(ext string, fn UnmarshalFn)
func SetFilePaths ¶
func SetFilePaths(filePaths ...string)
func SetFileSystem ¶
func SetFileSystem(fs FileSystem)
func SetProfileKey ¶
func SetProfileKey(profileKey string)
Types ¶
type DefaultConfigFn ¶
func CreateDefaultConfigFn ¶
func CreateDefaultConfigFn(defaultValue O) DefaultConfigFn
CreateDefaultConfigFn simplifica a criação de configurações genéricas
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry todas as propriedades são mapeadas para um tipo de dado abaixo, afim de respeitar corretamente a integração com Json
func ParseEntry ¶
type EntryKind ¶
type EntryKind uint
EntryKind representa os tipos de dados suportados na configuração, afim de manter compatibilidade total com arquivos JSON
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env propriedades de configuração de um site ou globais.
func (*Env) Load ¶
Load initialize default settings. A variable is obtained respecting the order below.
1) command line arguments (starting with "--", e.g. --server.port=9000) 2) DotEnv file variables ".env" 3) Operating system variables 4) Profile specific configuration (config-{dev|prod|test}.json) 5) global config (config.json) 6) Default config (cfg.New(DefaultConfig))
func (*Env) LoadDotEnv ¶
LoadDotEnv from https://github.com/joho/godotenv
func (*Env) LoadEnviron ¶
func (*Env) LoadObject ¶
LoadObject obtém as configurações a partir de um mapa em memória
func (*Env) LoadOsArgs ¶
LoadOsArgs will convert any command line option arguments (starting with ‘--’, e.g. --server.port=9000) to a property and add it to the Env.
Command line properties always take precedence over other property sources.
func (*Env) LoadOsEnv ¶
func (c *Env) LoadOsEnv()
LoadOsEnv obtém todas as configurações do ambiente
func (*Env) LoadProfiles ¶
LoadProfiles processa arquivos de configuração (config.json)
func (*Env) SetFileExt ¶
func (c *Env) SetFileExt(ext string, fn UnmarshalFn)
SetFileExt define o processador para essa extensão de arquivo. Usado para suportar .yaml, .toml, .xml
func (*Env) SetFilePaths ¶
SetFilePaths define o caminho dos arquivos de configuração.
func (*Env) SetFileSystem ¶
func (c *Env) SetFileSystem(fs FileSystem)
SetFileSystem define a instância do FileSystem que será usado para carregamento
func (*Env) SetProfileKey ¶
SetProfileKey define a key que identifica os arquivos de perfil de configuração.
func (*Env) TimeLayout ¶
TimeLayout obtém uma duração da config
type FileSystem ¶
type Logger ¶
type Logger interface { Error(string, ...interface{}) Info(string, ...interface{}) Warn(string, ...interface{}) }
Logger is implemented by any logging system that is used for standard logs.
type O ¶
type O map[string]interface{}
O representa um objeto JSON, usado para criação de configurações padrão