envars

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MergeEnvSlices

func MergeEnvSlices(base []string, over ...string) (merged []string)

MergeEnvSlices merges two slices into single, sorted, deduplicated slice by applying `over` slice into `base`. The `over` slice will be used if the key overlaps. See https://golang.org/pkg/os/exec/#Cmd `Env` field to read more about slice format.

Types

type EnvSlice

type EnvSlice []string

func EvalVariables

func EvalVariables(ctx context.Context, r io.Reader, envSlice ...string) (ret EnvSlice, _ error)

EvalVariables evaluates dot env file in similar way `bash source` would do and returns all environment variables available at end of the execution of the script. Currently it supports any bash script and can cause side effects. TODO(bwplotka): Walk over syntax and allow list few syntax elements only?

func (*EnvSlice) Each added in v0.4.3

func (e *EnvSlice) Each(f func(name string, vr expand.Variable) bool)

Each iterates over all the currently set variables, calling the supplied function on each variable. Iteration is stopped if the function returns false.

The names used in the calls aren't required to be unique or sorted. If a variable name appears twice, the latest occurrence takes priority.

Each is required to forward exported variables when executing programs.

func (*EnvSlice) Get added in v0.4.3

func (e *EnvSlice) Get(name string) expand.Variable

Get retrieves a variable by its name. To check if the variable is set, use Variable.IsSet.

func (EnvSlice) Lookup

func (e EnvSlice) Lookup(k string) (string, bool)

func (*EnvSlice) Set

func (e *EnvSlice) Set(kvs ...string)

Jump to

Keyboard shortcuts

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