config

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 9 Imported by: 0

README

config Eloquent configuration for Golang apps.

Go Reference

Features:

  • Substitutes $VARIABLE and ${VARIABLE} with variables found in a shell environment.
  • Syntaxes for setting up default values and specifying mandatory variables:
    • ${VARIABLE:-default} evaluates to default if VARIABLE is unset or empty in the environment.
    • ${VARIABLE-default} evaluates to default only if VARIABLE is unset in the environment.
    • ${VARIABLE:?err} panics with an error message containing err if VARIABLE is unset or empty in the environment.
    • ${VARIABLE?err} panics with an error message containing err if VARIABLE is unset in the environment.

Examples:

Documentation

Index

Constants

View Source
const (
	YAML = "yaml"
	JSON = "json"
	TOML = "toml"
)

Supported configuration file formats.

Should be used as a second argument to Load.

Variables

View Source
var OverwriteEnvPrefix = "CONFIG_OVERWRITE_"

Functions

func Load

func Load(in io.Reader, configType string, v interface{}) error

Load reads configuration data encoded in the format specified by configType from in and unmarshals it into v.

Load returns an error when data is in wrong or unsupported format, or when it failed to unmarshal data into v.

func LoadFile added in v0.1.1

func LoadFile(filename string, v interface{}) error

LoadFile reads configuration data from the named file and unmarshals it into v.

Internally it calls Load.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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