go-ozzo / ozzo-config Goto Github PK
View Code? Open in Web Editor NEWA Go (golang) package supporting layered application configuration in popular formats, such as JSON, YAML, TOML.
License: MIT License
A Go (golang) package supporting layered application configuration in popular formats, such as JSON, YAML, TOML.
License: MIT License
BurntSushi/toml
compatible with TOML version v0.2.0 only
Latest TOML tagged version: v0.4.0.
I have used successfully. https://github.com/naoina/toml
How about a general method to load data from a string or a io.Reader in addition to a file?
In some scenarios we need to save the configuration.
I builded a windows version of dalve and plugin that support it.
But when I debugging my App, i don't see any values loaded into this struct...
func LoadConfig() *config.Config{
// Load config
c := config.New()
c.Load("conf/config.json")
return c
}
{
"Version": "1.0",
"StaticServer": {
"Path": "./static"
},
"WebServer": {
"PortHTTP": "8080",
"PortHTTPS": "8088",
"Domain": "localhost"
},
"Logger": {
"Filename": "app.log",
"Email": "****@gmail.com"
},
"Db":{
"Type": "mysql",
"Host": "localhost",
"DbName": "inframe",
"Login": "root",
"Password": ""
}
}
There's a handy package created long time ago by Wei. Could be useful if you'll consider ini support: https://github.com/xwz/goconfig
TL;DR:
bug.json:
{"Head": {"StepSize": 2,"Hacks": {"Backup": {"A": 1,"Users": [1, 2, 3, 4],"S":"S"}}}}
cfg.Load("bug.json")
foo struct { Hacks struct { Backup struct { Users []int } } }
x:
cfg.Configure(&foo, "Head")
if len(foo.Hacks.Backup.Users) < 1 {
tries++
goto x
}
log.Println(fmt.Sprintf("ok done, took %d tries, got %v", tries, foo.Hacks.Backup.Users))
The results to get this structure parsed are varying between taking 8000 - 160000 tries on my machine, and this is not even supposed to work I guess. Test code: http://pastebin.com/FLQVtDYZ, tested on 1.6.2 and 1.8
{
"com": [
"foo",
"bar"
]
}
How to Deal this Data in JSON File?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.