env

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Env

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

An Env provides a simple interface to manipulate environment variables

func New

func New(env []string) *Env

New returns a new Env from an arbitrary list of variables

func NewFromOS

func NewFromOS() *Env

NewFromOS returns a new Env with variables from os.Environ()

func (*Env) Environ

func (e *Env) Environ() []string

Environ returns all variable as os.Environ() would

func (*Env) Get

func (e *Env) Get(name string) string

Get returns the value of a variable (defaults to empty string)

func (*Env) Has added in v0.10.0

func (e *Env) Has(name string) bool

Has returns whether the variable exists

func (*Env) Mutations added in v0.10.0

func (e *Env) Mutations() []VariableMutation

Mutations returns a list of variable mutations (previous and current value)

func (*Env) PrependToPath

func (e *Env) PrependToPath(path string)

PrependToPath inserts a new path at the beginning of the PATH variable

func (*Env) RemoveFromPath

func (e *Env) RemoveFromPath(substring string)

RemoveFromPath removes all path entries matching a substring

func (*Env) Set

func (e *Env) Set(name string, value string)

Set adds or changes a variable

func (*Env) Unset

func (e *Env) Unset(name string)

Unset removes a variable if it exists

type VariableMutation added in v0.10.0

type VariableMutation struct {
	Name     string
	Previous *variable
	Current  *variable
}

VariableMutation represents the change made on a variable

func (VariableMutation) DiffString added in v0.10.0

func (m VariableMutation) DiffString() string

DiffString returns a representation of the mutation as a diff

type Variables added in v0.10.0

type Variables map[string]*variable

func NewVariables added in v0.10.0

func NewVariables(environ []string) Variables

Jump to

Keyboard shortcuts

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