Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kennethanceyer/sparrow
:bird: Golang env based configure management module which is supported yaml, toml, json
https://github.com/kennethanceyer/sparrow
config configuration environment golang json manager stage toml yml
Last synced: about 2 months ago
JSON representation
:bird: Golang env based configure management module which is supported yaml, toml, json
- Host: GitHub
- URL: https://github.com/kennethanceyer/sparrow
- Owner: KennethanCeyer
- License: mit
- Created: 2019-08-09T02:23:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-03T16:39:22.000Z (almost 5 years ago)
- Last Synced: 2024-10-30T03:51:33.972Z (3 months ago)
- Topics: config, configuration, environment, golang, json, manager, stage, toml, yml
- Language: Go
- Homepage:
- Size: 41 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
sparrow
:bird: Golang env based configure management module which is supported yaml, toml, json
## Getting Started
### What is sparrow
sparrow is configure managing tool on Golang. When you need to separate configure file as file (toml, yml, json). This module easily read and parse them to pass the content to Golang code.
And sparrow supports environment isolation, When you use multiple stage for production, alpha and local. sparrow will overwrite specific env configuration to general configuration.
## Quick Start
### Installation
In your terminal
```bash
go get github.com/KennethanCeyer/sparrow
```In your code
```go
import "github.com/KennethanCeyer/sparrow"var config map[string]interface{}
err := sparrow.ReadFile("./your_config_path.yml", &config)
```### Example
> YAML file
```yaml
appName: 'sparrow'
appVersion: '1.0.0'
debug: true```
> JSON file
```json
{
"appName": "sparrow",
"appVersion": "1.0.0",
"debug": true
}
```> TOML file
```toml
appName = "sparrow"
appVersion = "1.0.0"
debug = true
``````go
import (
"github.com/KennethanCeyer/sparrow/sparrow"
"log"
)type Config struct {
AppName string
AppVersion string
Debug bool
}func main() {
var ymlConfig Config
var jsonConfig Config
var tomlConfig Config
var err errorerr = sparrow.ReadFile("./config.yml", &ymlConfig)
if err != nil {
return err
}err = sparrow.ReadFile("./config.json", &jsonConfig)
if err != nil {
return err
}err = sparrow.ReadFile("./config.toml", &tomlConfig)
if err != nil {
return err
}log.Println("ymlConfig", ymlConfig)
log.Println("jsonConfig", jsonConfig)
log.Println("tomlConfig", jsonConfig)return nil
}
```**OUTPUT**
```bash
2019/08/12 16:54:02 ymlConfig {sparrow 1.0.0 true}
2019/08/12 16:54:02 jsonConfig {sparrow 1.0.0 true}
2019/08/12 16:54:02 tomlConfig {sparrow 1.0.0 true}
```For your more information, Please check [the example](./example)
## Roadmap
### Configuration parser
- [x] YAML
- [x] JSON
- [x] TOML### Documentation
- [x] Example
- [ ] API Guide