added glob matching for ignored paths in hws
This commit is contained in:
21
env/LICENSE
vendored
Normal file
21
env/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 haelnorr
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
67
env/README.md
vendored
Normal file
67
env/README.md
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
# 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.
|
||||
18
env/doc.go
vendored
Normal file
18
env/doc.go
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// Package env provides utilities for reading environment variables with type safety
|
||||
// and default values. It supports common Go types including strings, integers (all sizes),
|
||||
// unsigned integers (all sizes), booleans, and time.Duration values.
|
||||
//
|
||||
// The package follows a simple pattern where each function takes a key name and a
|
||||
// default value, returning the parsed environment variable or the default if the
|
||||
// variable is not set or cannot be parsed.
|
||||
//
|
||||
// Example usage:
|
||||
//
|
||||
// port := env.Int("PORT", 8080)
|
||||
// debug := env.Bool("DEBUG", false)
|
||||
// timeout := env.Duration("TIMEOUT", 30*time.Second)
|
||||
//
|
||||
// All functions gracefully handle missing environment variables by returning the
|
||||
// provided default value. They also handle parsing errors by falling back to the
|
||||
// default value.
|
||||
package env
|
||||
Reference in New Issue
Block a user