setenv

package module
v0.0.0-...-46b7822 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2017 License: MIT Imports: 5 Imported by: 1

README

GoDoc

setenv

Simple add some env variables

Installation

Just use go get:

go get github.com/as27/setenv

Usage

Create a file

Create a textfile for example .setenv. The file accepts empty lines and comments with #. The logic is always KEY=VALUE.

APP_ID=abc12345
APP_SECRET=abc123456789

In that case the env variables APP_ID and APP_SECRET are going to be set.

Use in code

You can load the file inside your app. The best part would be the init() function to ensure that the enviroment variables are set before you get them over the code.

func init(){
    setenv.File(".setenv")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File

func File(filename string) error

File sets the env variables by a given file

func SetEnv

func SetEnv(envs []Env) error

SetEnv takes []Env and sets all entries

Types

type Env

type Env struct {
	Key   string
	Value string
}

Env defines Key and Value

func ParseFile

func ParseFile(filename string) ([]Env, error)

ParseFile takes a filename as input and returns the values as a slice. The file should be in the form: KEY1=VALUE1 KEY2=VALUE2 Spaces or empty lines are allowed. Comments begin with #

Jump to

Keyboard shortcuts

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