envutils

package
v0.0.0-...-5c79d48 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadEnvironmentFile

func ReadEnvironmentFile(filename string) ([]string, error)

ReadEnvironmentFile will read environment variables from a passed in location. Lines that start with "#" or empty lines are ignored. Assignments are in the form name=value and no variable expansion occurs.

Types

type SafeEnv

type SafeEnv []string

SafeEnv allows you to build a system environment while avoiding potentially dangerous environment conditions. In addition, SafeEnv will ignore any values added if the key already exists. This allows earlier inserts to take priority and ensure there is no conflicting values.

func (*SafeEnv) AddExecEnvironment

func (e *SafeEnv) AddExecEnvironment()

AddExecEnvironment will add safe values from os.Environ, ignoring any duplicates that may have already been added.

func (*SafeEnv) AddFullTrusted

func (e *SafeEnv) AddFullTrusted(fullValues ...string)

AddFullTrusted adds an exact value, in the KEY=VALUE format. This should only be used if they values are already combined. When the values are separate the [Add] function is generally preferred. This will not check for duplicates.

func (*SafeEnv) AddFullUnique

func (e *SafeEnv) AddFullUnique(fullValues ...string)

AddFullUnique adds an exact value, in the KEY=VALUE format. This should only be used if they values are already combined. When the values are separate the [Add] function is generally preferred. If any keys already exists (case-insensitive) they will be ignored.

func (*SafeEnv) AddTrusted

func (e *SafeEnv) AddTrusted(k, v string)

AddTrusted will add the key and value to the environment if it's a safe value to forward on for fork / exec. This will not check for duplicates.

func (*SafeEnv) AddUnique

func (e *SafeEnv) AddUnique(k, v string)

AddUnique will add the key and value to the environment if it's a safe value to forward on for fork / exec. If the key already exists (case-insensitive) it will be ignored.

Jump to

Keyboard shortcuts

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