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 Escape(key string) string
- 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]any, 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 Segments(key string) (segments []string)
- func SetFileExt(ext string, fn UnmarshalFn)
- func SetFilePaths(filePaths ...string)
- func SetFileSystem(fs FileSystem)
- 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
- func YamlUnmarshal(content []byte) (map[string]any, error)
- 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) Profiles() []string
- 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) 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 O
- type UnmarshalFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 Segments ¶ added in v1.0.4
Segments extract all key segments. (Ex. "assets.alias.bootstrap\.css.filepath" = ["assets", "alias", "bootstrap.css", "filepath"])
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 simplifies the creation of default configurations
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry all properties are mapped to a data type below, in order to correctly respect the integration with Json
func ParseEntry ¶
type EntryKind ¶
type EntryKind uint
EntryKind represents the data types supported in the configuration, in order to maintain full compatibility with JSON files
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
Env global instance.
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 get a time.Time using a layout
type FileSystem ¶
type FileSystem interface { Exists(filepath string) (bool, error) Read(filepath string) ([]byte, error) }
FileSystem Represents access to the file system.