67 lines
1.5 KiB
Markdown
67 lines
1.5 KiB
Markdown
# env v1.0.0
|
|
|
|
Environment variable utilities for Go applications with type safety and default values.
|
|
|
|
## Features
|
|
|
|
- Type-safe environment variable parsing
|
|
- Support for all basic Go types (string, int variants, uint variants, bool, time.Duration)
|
|
- Graceful fallback to default values
|
|
- Comprehensive boolean parsing with multiple truthy/falsy values
|
|
- Full test coverage
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
go get git.haelnorr.com/h/golib/env
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
"git.haelnorr.com/h/golib/env"
|
|
)
|
|
|
|
func main() {
|
|
// String values
|
|
host := env.String("HOST", "localhost")
|
|
|
|
// Integer values (all sizes supported)
|
|
port := env.Int("PORT", 8080)
|
|
timeout := env.Int64("TIMEOUT_SECONDS", 30)
|
|
|
|
// Unsigned integer values
|
|
maxConnections := env.UInt("MAX_CONNECTIONS", 100)
|
|
|
|
// Boolean values (supports many formats)
|
|
debug := env.Bool("DEBUG", false)
|
|
|
|
// Duration values
|
|
requestTimeout := env.Duration("REQUEST_TIMEOUT", 30*time.Second)
|
|
|
|
fmt.Printf("Server: %s:%d\n", host, port)
|
|
fmt.Printf("Debug: %v\n", debug)
|
|
fmt.Printf("Timeout: %v\n", requestTimeout)
|
|
}
|
|
```
|
|
|
|
## Documentation
|
|
|
|
See the [wiki documentation](../golib/wiki/env.md) for detailed usage information and examples.
|
|
|
|
## License
|
|
|
|
MIT License
|
|
|
|
## Contributing
|
|
|
|
Please see the main golib repository for contributing guidelines.
|
|
|
|
## Related Projects
|
|
|
|
This package is part of the golib collection of utilities for Go applications. |