env

package module
Version: v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: ISC Imports: 5 Imported by: 1

README

env

import "acln.ro/env"

GoDoc

Conveniences for working with environment variables from Go, in the context of executing external commands.

Documentation

Overview

Package env provides conveniences for working with environment variables, particularly in the context of executing external commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	Key    string
	MValue string
	NValue string
}

Change describes a change in a value in the environment.

func (Change) String

func (c Change) String() string

type Diff

type Diff struct {
	OnlyInM Map
	Changes []Change
	OnlyInN Map
}

Diff describes differences between two environments, "M" and "N".

type Map

type Map map[string]string

Map is a convenient representation of a set of environment variables.

func Merge

func Merge(maps ...Map) Map

Merge merges environment variable maps. In case of key collisions, values which appear later in the maps list take precedence.

func Parse

func Parse(kvs ...string) Map

Parse parses a list of environment variables in "key=value" format. Values not in "key=value" format are ignored.

func Variables

func Variables() Map

Variables returns a Map of the process environment.

func (Map) Diff

func (m Map) Diff(n Map) Diff

Diff computes differences between m and n.

func (Map) Encode

func (m Map) Encode() []string

Encode encodes the Map as a slice of "key=value" pairs, suitable for use with the os/exec package.

func (Map) Format

func (m Map) Format(s fmt.State, verb rune)

Format implements fmt.Formatter for Map as follows:

If the verb is anything but 'v', Format produces no output.

If the '+' flag is specified, Format emits newline separated "key=value" pairs. Otherwise, it emits space-separated "key=value" pairs.

Values are sorted lexicographically by key.

func (Map) String

func (m Map) String() string

String encodes the Map as space-separated "key=value" pairs, sorted lexicographically by key.

Source Files

Jump to

Keyboard shortcuts

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