https://github.com/siberia-projects/siberia-env
Siberia-env is a library written on clear go for working with environment variables
https://github.com/siberia-projects/siberia-env
easy-to-use env expansion framework go siberia
Last synced: 3 months ago
JSON representation
Siberia-env is a library written on clear go for working with environment variables
- Host: GitHub
- URL: https://github.com/siberia-projects/siberia-env
- Owner: siberia-projects
- License: apache-2.0
- Created: 2024-01-17T17:04:41.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-29T16:51:05.000Z (about 2 years ago)
- Last Synced: 2024-06-21T20:07:25.144Z (almost 2 years ago)
- Topics: easy-to-use, env, expansion, framework, go, siberia
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Siberia Env
=================
[](https://github.com/siberia-projects)
[](https://github.com/siberia-projects/siberia-env)

[](https://coveralls.io/github/siberia-projects/siberia-env?branch=main)
## What is it?
Siberia-env is a library written on clear go for working with environment variables
For now the library provides a method to expand all labeled (${ENV_VARIABLE_NAME})
environment variables in a content to their real values
## How to download?
```console
john@doe-pc:~$ go get github.com/siberia-projects/siberia-env
```
## How to use?
- Label places you want to expand in your content with "${}" symbols sequence
- Provide a name of a variable a value of which you want to extract
- (Optional) Provide a default value using ":" symbol (could be empty)
- Call the "env.ExpandEnvIn" method with the content
## Examples
```yaml
my:
custom:
properties:
headers:
- key: Cache-Control
value: ${CACHE_CONTROL:no-cache}
- key: Content-Type
value: application/json
```
```go
package main
import (
"github.com/siberia-projects/siberia-env/pkg/env"
"io"
"os"
)
func main() {
file, _ := os.Open("path_to_the_yaml_file_above.yaml")
defer file.Close()
fileContent, _ := io.ReadAll(file)
expandedFileContent, _ := env.ExpandEnvIn(fileContent)
expandedFileContentString := string(expandedFileContent)
println(expandedFileContentString)
}
```
```console
my:
custom:
properties:
headers:
- key: Cache-Control
value: no-cache
- key: Content-Type
value: application/json
```