Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jimeh/envctl

Go package providing test helper functions to temporarily change and restore environment variables.
https://github.com/jimeh/envctl

environment-variables go golang helper testing testing-tools

Last synced: 23 days ago
JSON representation

Go package providing test helper functions to temporarily change and restore environment variables.

Awesome Lists containing this project

README

        


envctl



Go package providing test helper functions to temporarily change and restore
environment variables.



Go Reference


GitHub tag (latest SemVer)


Actions Status


Coverage


GitHub issues


GitHub pull requests


License Status

```go
os.Setenv("PORT", "8080")

envctl.With(map[string]string{"BIND": "0.0.0.0", "PORT": "3000"}, func() {
fmt.Println(os.Getenv("BIND") + ":" + os.Getenv("PORT"))
})

fmt.Println(os.Getenv("BIND") + ":" + os.Getenv("PORT"))
```

```
0.0.0.0:3000
:8080
```

## Documentation

Please see the
[Go Reference](https://pkg.go.dev/github.com/jimeh/envctl#section-documentation)
for documentation and examples.

## Benchmarks

Benchmark reports and graphs are available here:
https://jimeh.me/envctl/dev/bench/

## License

[MIT](https://github.com/jimeh/envctl/blob/master/LICENSE)