config

package
v1.0.28 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// BaseConfig is the default configuration.
	// Configuration that is expected to be overridden by environment variables should be at the root level
	// and be simple values. Secrets should (probably) come from the environment and not be comitted with code.
	BaseConfig = map[string]interface{}{}

	// EnvMap maps a BaseConfig key onto the Environmental Key that overrides it.
	// Environmental configurations must be strings in the BaseConfig, though you can use the Get*
	// to convert to a desired type.
	// Environmental configs are those things which are:
	//     * Vital to the functionality of the service; or
	//     * Secret in nature
	// ex:
	// "host":              "HOST",
	// "port":              "PORT",
	// "defaultTimeout":    "TIMEOUT",
	// "env":               "ENV",
	// "dbConnectString":   "DB_CONNECT_STRING",
	EnvMap = map[string]string{}
)

Functions

func Get

func Get(key string) interface{}

Get returns the value of the given configuration element at the specified key as the JSON Type as it exists at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)

func GetBool

func GetBool(key string) bool

GetBool returns the value of the given configuration element at the specified key as an bool, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)

func GetInt

func GetInt(key string) int

GetInt returns the value of the given configuration element at the specified key as an int, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)

func GetMapStringBool

func GetMapStringBool(key string) map[string]bool

GetMapStringBool returns the value of the given configuration element at the specified key as map[string]bool, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)

func GetMapStringInt

func GetMapStringInt(key string) map[string]int

GetMapStringInt returns the value of the given configuration element at the specified key as map[string]int, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)

func GetMapStringInterface

func GetMapStringInterface(key string) map[string]interface{}

GetMapStringInterface returns the value of the given configuration element at the specified key as map[string]interface{}, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)

func GetMapStringString

func GetMapStringString(key string) map[string]string

GetMapStringString returns the value of the given configuration element at the specified key as map[string]string, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)

func GetString

func GetString(key string) string

GetString returns the value of the given configuration element at the specified key as a string, regardless of the original type at that key. Key is a valid JSON Path (https://goessner.net/articles/JsonPath/)

func Merge

func Merge(in []byte) error

Merge takes a json string and merges it into the current config.

Types

This section is empty.

Jump to

Keyboard shortcuts

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