configor

package
v0.0.0-...-0ae73c4 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ENV

func ENV() string

ENV return environment

func GetStringTomlKeys

func GetStringTomlKeys(list []toml.Key) []string

GetStringTomlKeys returns a string array of the names of the keys that are passed in as args

func Load

func Load(config interface{}, files ...string) error

Load will unmarshal configurations to struct from files that you provide

Types

type Config

type Config struct {
	Environment        string
	ENVPrefix          string
	Debug              bool
	Verbose            bool
	Silent             bool
	AutoReload         bool
	AutoReloadInterval time.Duration
	AutoReloadCallback func(config interface{})

	// In case of json files, this field will be used only when compiled with
	// go 1.10 or later.
	// This field will be ignored when compiled with go versions lower than 1.10.
	ErrorOnUnmatchedKeys bool
}

type Configor

type Configor struct {
	*Config
	// contains filtered or unexported fields
}

func New

func New(config *Config) *Configor

New initialize a Configor

func (*Configor) GetEnvironment

func (configor *Configor) GetEnvironment() string

GetEnvironment get environment

func (*Configor) GetErrorOnUnmatchedKeys

func (configor *Configor) GetErrorOnUnmatchedKeys() bool

GetErrorOnUnmatchedKeys returns a boolean indicating if an error should be thrown if there are keys in the config file that do not correspond to the config struct

func (*Configor) Load

func (configor *Configor) Load(config interface{}, files ...string) (err error)

Load will unmarshal configurations to struct from files that you provide

type UnmatchedTomlKeysError

type UnmatchedTomlKeysError struct {
	Keys []toml.Key
}

UnmatchedTomlKeysError errors are returned by the Load function when ErrorOnUnmatchedKeys is set to true and there are unmatched keys in the input toml config file. The string returned by Error() contains the names of the missing keys.

func (*UnmatchedTomlKeysError) Error

func (e *UnmatchedTomlKeysError) Error() string

Jump to

Keyboard shortcuts

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