https://github.com/0xthiebaut/go-config
A simple Go configuration module without overhead.
https://github.com/0xthiebaut/go-config
config configuration go golang strongly-typed
Last synced: 2 months ago
JSON representation
A simple Go configuration module without overhead.
- Host: GitHub
- URL: https://github.com/0xthiebaut/go-config
- Owner: 0xThiebaut
- License: eupl-1.2
- Created: 2021-09-28T08:21:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-28T19:59:12.000Z (over 3 years ago)
- Last Synced: 2025-03-20T10:07:59.927Z (2 months ago)
- Topics: config, configuration, go, golang, strongly-typed
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Go Config
A simple configuration module without overhead.**Why?**
Because all other libraries either did not restrict available configuration options or had an unneeded complexity.```go
package mainimport (
"fmt"
"github.com/0xThiebaut/go-config"
)type Config struct {
My string
Exotic map[string]Config
Configuration bool
}func main() {
demo := &Config{
My: "Demo",
}
c := config.New(&demo)
if s, err := c.ReadString("my"); err == nil {
fmt.Println(s)
// Output: Demo
}
if err := c.Write("my", "Hello World!"); err == nil {
fmt.Println(demo.My)
// Output: Hello World!
}
if err := c.Write("exotic.exotic.exotic.exotic.my", "Success!"); err == nil {
fmt.Println(demo.Exotic["exotic"].Exotic["exotic"].My)
// Output: Success!
}
}
```