fig

package module
v0.0.0-...-82edaa7 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2020 License: MIT Imports: 11 Imported by: 0

README

fig

reading and loading configuration from yaml / json files

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileOrder = []string{

	"./config/production.yaml",
	"./config/production.json",
	"production.yaml",
	"production.json",

	"./config/dev.yaml",
	"./config/dev.json",
	"dev.yaml",
	"dev.json",

	"./config/config.yaml",
	"./config/config.json",
	"config.yaml",
	"config.json",
}

FileOrder contains the name, path and order in which the configuration files will be read. The first file will have highest priority

View Source
var ShowFiles = false

ShowFiles if set to true, will output the files to StdOut which were read to build the overall configuration

Functions

func Bool

func Bool(keys ...string) bool

Bool returns the bool value at the given key. Panics if the key is missing.

func BoolOr

func BoolOr(defaultVal bool, keys ...string) bool

BoolOr returns the bool value at the given key. If key is missing it returns defaultVal

func Exists

func Exists(keys ...string) bool

Exists checks if the given key is present. It also loads configuration (if missing)

func Float

func Float(keys ...string) float64

Float returns the float value at the given key. Panics if the key is missing.

func FloatOr

func FloatOr(defaultVal float64, keys ...string) float64

FloatOr returns the float64 value at the given key. If key is missing it returns defaultVal

func Int

func Int(keys ...string) int

Int returns the int value at the given key. Panics if the key is missing.

func IntOr

func IntOr(defaultVal int, keys ...string) int

IntOr returns the int value at the given key. If key is missing it returns defaultVal

func Interface

func Interface(keys ...string) interface{}

Interface returns the generic value corresponding to a key.

func Map

func Map(keys ...string) map[string]interface{}

Map returns a map a the given key. Panics if the key is missing.

func MustExist

func MustExist(key string)

MustExist panics if the given configuration key is missing

func String

func String(keys ...string) string

String returns the string value at the given key. Panics if the key is missing.

func StringOr

func StringOr(defaultVal string, keys ...string) string

StringOr returns the string value at the given key. If key is missing it returns defaultVal

func StringSlice

func StringSlice(keys ...string) []string

StringSlice returns a splice of string at the given key. Panics if the key is not present.

func StringSliceOr

func StringSliceOr(defaultVal []string, keys ...string) []string

StringSliceOr returns a splice of string at the given key. If key is missing it returns defaultVal.

func Struct

func Struct(addr interface{}, keys ...string)

Struct is used to parse and load simple structures. Most common use is reading connection strings. Note that it does not work for nested structs or arrays

Types

This section is empty.

Jump to

Keyboard shortcuts

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