ankrscan-config
Library for Ankr Scan services configuration
Usage example
YAML:
my-service:
db:
host: production
port: 5000
my-flag: false
Go:
type Config struct {
Database struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
} `mapstructure:"db"`
MyFlag bool `mapstructure:"my-flag"`
}
func NewConfig() (*Config, error) {
var config Config
var defaults = map[string]interface{}{
"db.host": "localhost",
"db.port": 5000,
"my-flag": false,
}
err := configutil.Load("my-service", &config, defaults, log.StandardLogger())
if err != nil {
return nil, err
}
return &config, nil
}
Default config config.local.yaml
is suitable for local development.
To specify different config files or path, use environment variables CONFIG_FILE
, CONFIG_PATH
.
CONFIG_FILE
accepts list of config files split by whitespaces. Config values from the files are merged in provided order.