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: 9 months ago
JSON representation
Go package providing test helper functions to temporarily change and restore environment variables.
- Host: GitHub
- URL: https://github.com/jimeh/envctl
- Owner: jimeh
- License: mit
- Created: 2021-01-13T11:03:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-17T20:57:05.000Z (over 5 years ago)
- Last Synced: 2025-08-18T08:02:04.348Z (11 months ago)
- Topics: environment-variables, go, golang, helper, testing, testing-tools
- Language: Go
- Homepage: https://pkg.go.dev/github.com/jimeh/envctl
- Size: 23.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
envctl
Go package providing test helper functions to temporarily change and restore
environment variables.
```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)