envmap

package
v0.0.0-...-8e26044 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package envmap is a set of utility functions to manage a process environment as a map between the environment variable names and their value

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnvironmentMap

type EnvironmentMap map[string]string

EnvironmentMap represent a map between environment variable names and their value.

func Merge

func Merge(e1, e2 EnvironmentMap) EnvironmentMap

Merge merges two environment maps. When a key in e1 is also present in e2, the value associated with the key in e2 will be used.

func Parse

func Parse(env []string) (EnvironmentMap, error)

Parse parses a list of strings in the form "foo=bar" into an environment map. If an envalid string is detected, this function will return a ErrWrongEnvironmentString error for the invalid entry.

func ParseEnviron

func ParseEnviron() (EnvironmentMap, error)

ParseEnviron returns the environment of the current process.

func (EnvironmentMap) StringSlice

func (e EnvironmentMap) StringSlice() []string

StringSlice converts an environment map to a list of strings in the form "foo=bar". The returned list is sorted in lexicographic key order.

type ErrWrongEnvironmentString

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

ErrWrongEnvironmentString is raised when the Parse function detects a wrong environment string. By convention, the strings in environment should have the form "name=value".

See: https://www.man7.org/linux/man-pages/man7/environ.7.html

func (*ErrWrongEnvironmentString) Error

func (e *ErrWrongEnvironmentString) Error() string

Error implements the error interface.

Jump to

Keyboard shortcuts

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