https://github.com/nao1215/denv
"denv" is a library that manages the deployment environment, which can be one of development, integration, staging, or production.
https://github.com/nao1215/denv
deployment-environment golang runtime
Last synced: 4 months ago
JSON representation
"denv" is a library that manages the deployment environment, which can be one of development, integration, staging, or production.
- Host: GitHub
- URL: https://github.com/nao1215/denv
- Owner: nao1215
- License: mit
- Created: 2023-09-19T03:07:40.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T13:36:25.000Z (almost 2 years ago)
- Last Synced: 2025-10-04T22:26:03.450Z (8 months ago)
- Topics: deployment-environment, golang, runtime
- Language: Go
- Homepage:
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README

[](https://github.com/nao1215/denv/actions/workflows/linux_test.yml)
[](https://github.com/nao1215/denv/actions/workflows/mac_test.yml)
[](https://github.com/nao1215/denv/actions/workflows/windows_test.yml)
[](https://github.com/nao1215/denv/actions/workflows/freebsd.yml)
[](https://github.com/nao1215/denv/actions/workflows/netbsd.yml)
[](https://github.com/nao1215/denv/actions/workflows/openbsd.yml)
[](https://github.com/nao1215/denv/actions/workflows/dragonfly.yml)
[](https://github.com/nao1215/denv/actions/workflows/security.yml)
[](https://github.com/nao1215/denv/actions/workflows/govulncheck.yml)
[](https://github.com/nao1215/denv/actions/workflows/reviewdog.yml)
[](https://pkg.go.dev/github.com/nao1215/denv)
[](https://goreportcard.com/report/github.com/nao1215/denv)
# denv
"denv" is a library that manages the deployment environment, which can be one of development, integration, staging, or production.
## How to use
1. You import the library: "github.com/nao1215/denv"
2. You set the environment variable "APP_ENV" to one of "development", "integration", "staging", or "production".
3. You create a new Env instance with denv.NewEnv().
```go
func Example() {
if err := os.Setenv("APP_ENV", denv.Staging); err != nil {
fmt.Println("Error setting environment variable:", err)
return
}
// Create a new Env instance.
env, err := denv.NewEnv()
if err != nil {
fmt.Println("Error creating environment:", err)
return
}
// Print the current environment.
fmt.Printf("Current environment: %s\n", env.String())
// Check if it's the development environment.
if env.IsDevelopment() {
fmt.Println("This is the development environment.")
} else {
fmt.Println("This is not the development environment.")
}
// Check if it's the production environment.
if env.IsProduction() {
fmt.Println("This is the production environment.")
} else {
fmt.Println("This is not the production environment.")
}
// Output:
// Current environment: staging
// This is not the development environment.
// This is not the production environment.
}
```
## Support OS & go version
- Linux
- Mac
- Windows
- FreeBSD
- OpenBSD
- NetBSD
- DragonflyBSD
- go version 1.20 or later
## LICENSE
[MIT](./LICENSE)