config

package module
v0.0.0-...-13cfef1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 10 Imported by: 0

README

config

Configuration management for golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfMgr

type ConfMgr struct {

	// Set Log if you want to see extra logging from config manager
	Log *log.Logger
	//
	ConfigPaths  []string
	EnvVarPrefix string
	// contains filtered or unexported fields
}

func NewConfMgr

func NewConfMgr(configName string) *ConfMgr

NewConfMgr creates new instance of ConfMgr configName is name of config file name without extension

func (*ConfMgr) BindFlag

func (c *ConfMgr) BindFlag(confKey string, flag *pflag.Flag) error

func (*ConfMgr) ReadConfig

func (c *ConfMgr) ReadConfig(flags *pflag.FlagSet, configStruct interface{}) error

type ConfigReader

type ConfigReader interface {
	// ReadConfig reads config from config file, env vars or flags. In case of error fails with os.Exit(1)
	ReadConfig(flags *pflag.FlagSet, rawVal interface{}) error
	BindFlag(confKey string, flag *pflag.Flag) error
}
 CodefigReader allows commands to read configuration from config file, env vars or flags.
 Flags have precedence over env vars and evn vars have precedence over config file.
 Flags mapped to config struct filed automatically if their name includes path to field.
 For example:
	type NestedConf struct {
		Foo string
	}

  	type Config struct{
      Nested NestedConf
 	}

in that case flag --nested.foo will be mapped automatically This flag could be also set by UKAMA_NESTED_FOO env var or by creating config file .ukama.yaml: nested:

foo: bar

type GlobalConfig

type GlobalConfig struct {
	Verbose bool
}

Jump to

Keyboard shortcuts

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