env

package
v3.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 25, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Environment

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

Environment is a map of environment variables, with the keys normalized for case-insensitive operating systems

func FromExport

func FromExport(body string) *Environment

FromExport parses environment variables from a shell export of environment variables. On *nix it looks like this:

$ export -p
declare -x USER="keithpitt"
declare -x VAR1="boom\\nboom\\nshake\\nthe\\nroom"
declare -x VAR2="hello
friends"
declare -x VAR3="hello
friends
OMG=foo
test"
declare -x VAR4="great
typeset -x TOTES=''
lollies"
declare -x XPC_FLAGS="0x0"

And on Windowws...

$ SET
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\IEUser\AppData\Local\Temp
TMP=C:\Users\IEUser\AppData\Local\Temp
USERDOMAIN=IE11WIN10

func FromSlice

func FromSlice(s []string) *Environment

FromSlice creates a new environment from a string slice of KEY=VALUE

func New

func New() *Environment

func (*Environment) Copy

func (e *Environment) Copy() *Environment

Copy returns a copy of the env

func (*Environment) Diff

func (e *Environment) Diff(other *Environment) *Environment

Diff returns a new environment with all the variables that have changed

func (*Environment) Exists

func (e *Environment) Exists(key string) bool

Exists returns true/false depending on whether or not the key exists in the env

func (*Environment) Get

func (e *Environment) Get(key string) (string, bool)

Get returns a key from the environment

func (*Environment) GetBool

func (e *Environment) GetBool(key string, defaultValue bool) bool

Get a boolean value from environment, with a default for empty. Supports true|false, on|off, 1|0

func (*Environment) Length

func (e *Environment) Length() int

Length returns the length of the environment

func (*Environment) Merge

func (e *Environment) Merge(other *Environment) *Environment

Merge merges another env into this one and returns the result

func (*Environment) Remove

func (e *Environment) Remove(key string) string

Remove a key from the Environment and return it's value

func (*Environment) Set

func (e *Environment) Set(key string, value string) string

Set sets a key in the environment

func (*Environment) ToMap

func (e *Environment) ToMap() map[string]string

ToMap returns a map representation of the environment

func (*Environment) ToSlice

func (e *Environment) ToSlice() []string

ToSlice returns a sorted slice representation of the environment

Jump to

Keyboard shortcuts

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