environ

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Environ

type Environ []string

environ is a slice of strings representing the environment, in the form "key=value".

func (*Environ) IsSet

func (e *Environ) IsSet(key string) bool

IsSet returns whether or not a key is currently set in the environ

func (*Environ) Load

func (e *Environ) Load(ctx context.Context, s store.Store, service string, collisions *[]string) error

Load loads environment variables into e from s given a service collisions will be populated with any keys that get overwritten

func (*Environ) LoadStrict

func (e *Environ) LoadStrict(ctx context.Context, s store.Store, valueExpected string, pristine bool, services ...string) error

LoadStrict loads all services from s in strict mode: env vars in e with value equal to valueExpected are the only ones substituted. If there are any env vars in s that are also in e, but don't have their value set to valueExpected, this is an error.

func (*Environ) Map

func (e *Environ) Map() map[string]string

Map squashes the list-like environ, taking the latter value when there are collisions, like a shell would. Invalid items (e.g., missing `=`) are dropped

func (*Environ) Set

func (e *Environ) Set(key, val string)

Set adds an environment variable, replacing any existing ones of the same key

func (*Environ) Unset

func (e *Environ) Unset(key string)

Unset an environment variable by key

type ErrExpectedKeyUnnormalized

type ErrExpectedKeyUnnormalized struct {
	Key           string
	ValueExpected string
}

func (ErrExpectedKeyUnnormalized) Error

type ErrStoreMissingKey

type ErrStoreMissingKey struct {
	// env-style key
	Key           string
	ValueExpected string
}

func (ErrStoreMissingKey) Error

func (e ErrStoreMissingKey) Error() string

type ErrStoreUnexpectedValue

type ErrStoreUnexpectedValue struct {
	// store-style key
	Key           string
	ValueExpected string
	ValueActual   string
}

func (ErrStoreUnexpectedValue) Error

func (e ErrStoreUnexpectedValue) Error() string

Jump to

Keyboard shortcuts

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