Documentation
¶
Overview ¶
A simple way to manage environment variables. (Minimal Go version: 1.21)
Note: Variable names in virtual environment are case sensitive. This package is not concurrency safe.
Index ¶
- type Venv
- func (v Venv) Clearenv() Venv
- func (v Venv) Environ() []string
- func (v Venv) ExpandEnv(s string) string
- func (v Venv) ExpandEnvHybrid(s string) string
- func (v Venv) ExpandEnvInMap(m map[string]string) map[string]string
- func (v Venv) ExpandEnvInSlice(s []string) []string
- func (v Venv) FromEnv() Venv
- func (v Venv) FromJson(data []byte, expand bool) error
- func (v Venv) FromMap(newMap map[string]string, expand bool) Venv
- func (v Venv) FromSlice(newSlice []string, expand bool) Venv
- func (v Venv) Getenv(key string) string
- func (v Venv) LookupEnv(key string) (string, bool)
- func (v Venv) Setenv(key string, val string)
- func (v Venv) Setvar(pair string)
- func (v Venv) ToEnv() error
- func (v Venv) ToJson() ([]byte, error)
- func (v Venv) ToMap() map[string]string
- func (v Venv) ToSlice() []string
- func (v Venv) Unsetenv(key string)
- type VenvDiff
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Venv ¶
Type of virtual environment. It is a Map, so you can manipulate virtual environments just like you would a Map.
func (Venv) ExpandEnvHybrid ¶
ExpandEnv with a fallback approach. Prioritize searching in the virtual environment, and if not, using variables from the actual environment.
func (Venv) ExpandEnvInMap ¶
Apply ExpandEnvHybrid to each value in map. This method directly modifies the original Map/Slice passed in.
func (Venv) ExpandEnvInSlice ¶
Apply ExpandEnvHybrid to each element in slice. This method directly modifies the original Map/Slice passed in.
func (Venv) FromJson ¶
Update virtual environment from JSON JSON Format: [{"key": "KEY", "value": "VALUE"}...]
func (Venv) Setvar ¶
Update virtual environment by key-value pair. If there is no "=", the variable will be unset.
func (Venv) ToEnv ¶
Apply virtual environment to actual environment. This operation terminates on error, but does not have the ability to restore environment variables.
func (Venv) ToJson ¶
Export virtual environment to JSON. JSON Format: [{"key": "KEY", "value": "VALUE"}...] This operation is out of order.