https://github.com/virskor/gin-config
Using json for configrations on gin application
https://github.com/virskor/gin-config
Last synced: 3 months ago
JSON representation
Using json for configrations on gin application
- Host: GitHub
- URL: https://github.com/virskor/gin-config
- Owner: virskor
- Created: 2019-03-30T03:30:28.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-07-23T15:19:30.000Z (almost 6 years ago)
- Last Synced: 2025-01-08T17:52:40.427Z (5 months ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gin-config
Using json for configrations on gin application.### Usage
```sh
go get github.com/virskor/gin-config
```### Config file
Save config.json file as debug/release .json file in defined root path.
We use different json file in different enviroment.
``` go
configs/app/debug.json || release.json
```
Filename is same with your gin.Mode().debug.json
```json
{
"application": {
"name": "example"
},
"db": {
"driver": "mysql",
"password": "",
// ...
}
}
```### Example
```go
import (
ginc "github.com/virskor/gin-config"
"fmt"
)var conf *ginc.Config
func main(){
applicationName:= ginc.Get(&ginc.ConfigOptions(Key: "application.name"))fmt.Println("result", applicationName)
}
```ginc.ConfigOptions
```go
type ConfigOptions struct {
Key string //important, grammar would like gson
File string
}
```