env

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(filenames ...string) map[string]string

Get first tries to read the passed files and then overrides the .env file parameters with the environment variables in memory. this is useful in order to have a base configuration that is within a file that can contain like a common password for every econ, but must override its econ address (IP:Port) with an environment variable. The passed filenames can be omitted, but may be used to pass a list of files.

func GetEnv

func GetEnv() map[string]string

GetEnv returns a map of OS environment variables

func Parse

func Parse(filename string, cfg configo.Config) error

Parse uses my simple-configo package that allows to easily parse environment maps and do proper value conversions as well as setting your configuration's struct fields after parsing the values. All you do is define a Configuration struct, add any of the common struct field values, implement the Options() configo.Options function and you are ready to parse any arbitrary environment format like string, regex match, integer, bool, time ranges, etc. filenames is an optional parameter, if it is left empty, the underlying library will try to open the .env file in the same directory first and then parse those values afterwards the environment variables override any value from that file.

func Read

func Read(filenames ...string) (map[string]string, error)

Read reads .env files that are passed to this function and returns a map of key values .env files have the same syntax as environment variables KEY=VALUE

Types

This section is empty.

Jump to

Keyboard shortcuts

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