config

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: ISC Imports: 4 Imported by: 0

Documentation

Overview

Package config implements a simple global configuration system that supports a file with key=value pairs and environment variables. Note that the config system is global.

This package is intended to be used for small daemons: some configuration file is optionally populated at program start, then this is used to transparently look up configuration values from either that file or the environment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(key string) string

Get retrieves a value from either a configuration file or the environment. Note that values from a file will override environment variables.

func GetDefault

func GetDefault(key, def string) string

GetDefault retrieves a value from either a configuration file or the environment. Note that value from a file will override environment variables. If a value isn't found (e.g. Get returns an empty string), the default value will be used.

func LoadFile

func LoadFile(path string) error

LoadFile scans the file at path for key=value pairs and adds them to the configuration.

func Require

func Require(key string) string

Require retrieves a value from either a configuration file or the environment. If the key isn't present, it will call log.Fatal, printing the missing key.

func SetEnvPrefix

func SetEnvPrefix(pfx string)

SetEnvPrefix sets the prefix for all environment variables; it's assumed to not be needed for files.

Types

This section is empty.

Jump to

Keyboard shortcuts

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