https://github.com/awatercolorpen/config
a lightweight pluggable dynamic config package without useless dependencies
https://github.com/awatercolorpen/config
config dynamic-loading golang lightweight pluggable
Last synced: about 1 year ago
JSON representation
a lightweight pluggable dynamic config package without useless dependencies
- Host: GitHub
- URL: https://github.com/awatercolorpen/config
- Owner: AWaterColorPen
- License: apache-2.0
- Created: 2023-02-06T12:24:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-07T02:58:16.000Z (over 3 years ago)
- Last Synced: 2024-06-20T06:27:10.850Z (almost 2 years ago)
- Topics: config, dynamic-loading, golang, lightweight, pluggable
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# config
[](https://github.com/AWaterColorPen/config/actions/workflows/go.yml)
## Introduction
Config is a lightweight pluggable dynamic config package without useless dependencies.
Base on forked from [github.com/go-micro/go-micro/config](https://github.com/go-micro/go-micro/tree/master/config).
## Features
- dynamic loading
- pluggable sources
- mergeable config
- observe changes
- sane defaults
## Getting Started
### Load and get
load config from `env`, `flag` and `file`.
```golang
if err := config.Load(env.NewSource()); err != nil {
return err
}
if err := config.Load(flag.NewSource(flag.IncludeUnset(true))); err != nil {
return err
}
configFile := "config_file.json"
if err := config.Load(file.NewSource(file.WithPath(configFile))); err != nil {
return err
}
```
get config to struct
```golang
func Scan(v any, path ...string) error {
return config.Get(path...).Scan(v)
}
```
## License
See the [License File](./LICENSE).