env

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReversePaths

func ReversePaths(a []string) []string

ReversePaths reverses a list of paths and returns a new slice.

Types

type Change

type Change struct {
	Key      string
	Val      string
	Restored bool
}

Change describes a single environment variable change.

type ChangeList

type ChangeList []Change

ChangeList is a slice of changes, with added sort interface. The sort.Interface lists restored changes first and sorts by Key.

func (ChangeList) Len

func (cl ChangeList) Len() int

func (ChangeList) Less

func (cl ChangeList) Less(i, j int) bool

func (ChangeList) Swap

func (cl ChangeList) Swap(i, j int)

type Env

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

Env keeps track of changes to environment variables

func New

func New() *Env

New returns a new Env

func (*Env) Changes

func (e *Env) Changes() (changes ChangeList)

Changes returns all changes to environment variables

func (*Env) Get

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

Get returns the current value for an environment variable.

func (*Env) Restore

func (e *Env) Restore(key, val string)

Restore sets an environment variable to a previous value and marks it as restored.

func (*Env) Set

func (e *Env) Set(key, val string)

Set sets an environment variable to a new value.

type Path

type Path struct {
	Changed bool
	Added   map[string]bool
	Removed map[string]bool
	// contains filtered or unexported fields
}

Path contains operations for paths in a PATH env var.

func NewPath

func NewPath(paths []string) *Path

NewPath returns a new Path

func (*Path) Add

func (p *Path) Add(path string)

Add adds a path to the list of paths.

func (*Path) Get

func (p *Path) Get() []string

Get returns the list of paths.

func (*Path) GetReversed

func (p *Path) GetReversed() []string

GetReversed returns the list of paths reversed.

func (*Path) Has

func (p *Path) Has(path string) bool

Has checks if a path is already included in the list of paths.

func (*Path) Remove

func (p *Path) Remove(path string)

Remove removes a path from the list of paths.

Jump to

Keyboard shortcuts

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