proxy.golang.org : github.com/oxplot/starenv
Package starenv implements populating environmental variables from variety of sources. Simplest way to use starenv is to import the autoload package: The above will iterate through all environmental variables looking for specially formatted values which tell it where to load the final values from. After the above is imported, you can use the usual os.Getenv() to get the value of environmental variables. The source of a value is defined as a pipeline of "derefer" tags followed by the reference for the last derefer. Here is an example of a environmental variable specifying to load its value from a base64 encoded file and decrypt it using GPG: Each derefer is applied in reverse, starting with "file" which loads the content of "~/.github_token". "b64" then decodes it and finally "gpg" decrypts it. If the value of an environmental variable starts with Loader.Star (which defaults to "*"), it is treated as a pipeline. Otherwise, it's treated as a literal value and left unchagned. In the unlikely case where a literal value starting with Loader.Star is needed, the following can be used: Here the blank derefer treats everything after "*:" as literal and returns it, thus leading to GLOB_PAT being set to "*.terraform". Package autoload registers a set of derefers that are included in derefer package with appropriate tags. To have more control over tags and the timing of when the loading happens, you can register each derefer manually and call Load() to populate the env vars. When using the autoload package, .env file is also read and loaded. To disable this, set DOTENV_ENABLED=0. Any type that implements Derefer methods can be registered and used in the pipeline.
Registry
-
Source
- Documentation
- JSON
purl: pkg:golang/github.com/oxplot/starenv
License: BSD-3-Clause
Latest release: about 2 years ago
First release: over 3 years ago
Namespace: github.com/oxplot
Dependent repositories: 1
Stars: 6 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 1 day ago