ankrscan-config

module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: MIT

README

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.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL