env

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

README

Environment variable loader

Very simple package to load the variables from a standard environment file (usually .env in the root).

Optionally allows any key within the environment file to be overridden by actual os environment variables, this is good to allow defaults and have production env variables override file defined ones.

Usage

go get github.com/SamuelBanksTech/env

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(key string) string

Get simply returns the matching key value

Types

type Environment

type Environment struct {
	// EnvPath is the path to your environment varible file, usually .env in the root but can be whatever you like
	EnvPath string
	// EnableOsEnvOverride allows any matching os level environment variables to override any contained in the environment file
	EnableOsEnvOverride bool
	// HideOutput simply shows or hides console output of parsed environment variables
	HideOutput bool
}

Environment struct

func (*Environment) LoadEnv

func (e *Environment) LoadEnv() error

LoadEnv loads the specified environment file and splits them into key value pairs these are then stored in a globally accessible map via a getter method if Environment.EnableOsOverride is set to true any matching keys that exist in the actual environment will override the value in the file

Jump to

Keyboard shortcuts

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