https://github.com/metafates/conphig
⚙️ A better way to manage configs in Go
https://github.com/metafates/conphig
Last synced: 5 months ago
JSON representation
⚙️ A better way to manage configs in Go
- Host: GitHub
- URL: https://github.com/metafates/conphig
- Owner: metafates
- License: unlicense
- Created: 2023-10-16T19:40:07.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-16T20:12:26.000Z (about 2 years ago)
- Last Synced: 2025-06-02T05:55:01.979Z (7 months ago)
- Language: Go
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ⚙️ Conφg
> Spells like "con-phi-g"
A better way to manage Go apps configuration
```go
var PositiveInteger = conphig.New[int, int](
"positive_integer",
42,
conphig.ID[int],
conphig.WithDescription[int, int]("Positive integer > 0"),
conphig.WithValidateFunc[int](func(i int) error {
if i <= 0 {
return fmt.Errorf("expected >= 0, got %d", i)
}
return nil
}),
)
var FooBar = conphig.New[string, string](
"foobar",
"${EDITOR}, $USER and $HOME",
conphig.ID[string],
conphig.WithDescription[string, string]("String with env variables"),
conphig.WithAdjustFunc[string, string](func(s string) (string, error) {
return os.ExpandEnv(s), nil
}),
)
var Time = conphig.New[string, time.Time](
"time",
time.Now(),
func(s string) (time.Time, error) {
return time.Parse(time.Kitchen, s)
},
)
```
> [!NOTE]
> Work in progress, API may change
## How to use
Conphig extends awesome [koanf](https://github.com/knadh/koanf) library.
See [examples](./examples) for examples how to use this library.