config_loader

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(config Configuration, options ...ConfigOption) error

Load loads the configuration from the given config file.

Rules:

- The config file must be either a JSON or YAML file.

- All fields must be exported.

- Fields without env tag will be uppercase and used as environment variable name.

Types

type ConfigOption added in v0.0.15

type ConfigOption func(*LoaderOpts)

func ConfigPath added in v0.0.15

func ConfigPath(path string) ConfigOption

ConfigPath sets the path to the config file.

func EnvFileName added in v0.2.7

func EnvFileName(envFileName string) ConfigOption

EnvFileName sets the name of the .env file, defaults to .env

func EnvPrefix added in v0.0.15

func EnvPrefix(prefix string) ConfigOption

EnvPrefix sets the prefix for environment variables. Will capitalize the prefix.

func ErrorIfNotFound added in v0.0.15

func ErrorIfNotFound(errorIfNotFound bool) ConfigOption

ErrorIfNotFound sets the flag that determines whether an error should be returned if the config file is not found.

func RootDir added in v0.2.7

func RootDir(rootDir string) ConfigOption

RootDir sets the directory to look for .env files

type Configuration

type Configuration any

type LoaderOpts

type LoaderOpts struct {
	// contains filtered or unexported fields
}

LoaderOpts is a struct that contains options for the config loader.

Jump to

Keyboard shortcuts

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