environment

package
v0.12.0-beta2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package environment supports environment variable format conversion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromMap

func FromMap(environment map[string]string) []string

FromMap converts a map of environment variables into a slice of "KEY=value" strings. If the provided environment is nil, then the resulting slice will be nil. If the provided environment is non-nil but empty, then the resulting slice will be empty. These two properties are critical to usage with the os/exec package.

func ParseBlock

func ParseBlock(block string) []string

ParseBlock parses an environment variable block of the form VAR1=value1[\r]\nVAR2=value2[\r]\n... into a slice of KEY=value strings. It opts for performance over extensive format validation.

func ToMap

func ToMap(environment []string) map[string]string

ToMap converts an environment variable specification from a slice of "KEY=value" strings to a map with equivalent contents. Any entries not adhering to the specified format are ignored. Entries are processed in order, meaning that the last entry seen for a key will be what populates the map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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