stvp / go-toml-config Goto Github PK
View Code? Open in Web Editor NEWTOML-based config for Go
License: MIT License
TOML-based config for Go
License: MIT License
Looking it's wrapper for flag
you probably will not support arrays?
Best regards,
Dobrosław Żybort
As there is no array in flagset, so will go-toml-config support it?
In which way?
Hi,
i have the following config file myconf.conf:
[facebook]
appId = "somenumbers"
appSecret = "aString"
When I call
err := config.Parse("../conf/myconf.conf")
I get the error
facebook.appId is not a valid config setting.
Why? :(
Thanks!
I like from Python ConfigParser option to load many config files:
from ConfigParser import SafeConfigParser
parser = SafeConfigParser()
parser.read(['does_not_exist.ini', 'config.ini', 'config_dev.ini', ])
print 'Log level:', parser.get('logging', 'log_level')
print 'Prefix:', parser.get('logging', 'prefix')
if 'config.ini
:
[logging]
log_level = info
prefix = 'my_prefix'
and config_dev.ini
:
[logging]
log_level = debug
Output would be:
Log level: debug
Prefix: "my_prefix"
ConfigParser overwrites the keys with each successive file, the order in which the files are read is determined by the order of the file names in the list passed to ConfigParser.read
Docs: http://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser.read
Would be nice if you could add something similar.
Best regards,
Dobrosław Żybort
e.g. lets say I have environment variables for the database password? How would I use this to link to that environment variable
I am using the following setup...
main.go
package main
import (
"fmt"
"github.com/stvp/go-toml-config"
)
var (
country string
atlantaEnabled bool
alantaPopulation int
)
func main() {
config.StringVar(&country, "country", "Unknown")
config.BoolVar(&atlantaEnabled, "atlanta.enabled", false)
config.IntVar(&alantaPopulation, "atlanta.population", 0)
config.Parse("./test.conf")
fmt.Printf("Country: %v\n", country)
fmt.Printf("AtlantaEnabled: %v\n", atlantaEnabled)
fmt.Printf("AlantaPopulation: %v\n", alantaPopulation)
}
test.conf
country = "USA"
[atlanta]
enabled = true
population = 432427
temperature = 99.6
Sometimes I get the configured values:
Country: USA
AtlantaEnabled: true
AlantaPopulation: 432427
And other times I get the default values:
Country: Unknown
AtlantaEnabled: false
AlantaPopulation: 0
And other times I get a mix of both:
Country: Unknown
AtlantaEnabled: true
AlantaPopulation: 432427
Any help would be appreciated.
hey, cool little lib. i used it for a few apps.
i have an ini file that's used by 2 different apps (a golang app and a shellscript).
so the ini file contains some settings that are not revelant to the golang app, which makes this lib complain about not being a valid config setting.
is there any solution for this?
These feature is so simple, can you support these, so that it will be used the same as flag package
Like everyone I started to use this pkg but when I browse to the docs URL it says:
Documentation not displayed due to license restrictions.
See our license policy.
I think you should have a LICENSE
file at the root of the repo in the order for it to work.
From what I can tell, an option name like
"db-connections" is invalid in toml, it has to be "db_connections". However the library does not reject such names. When parsing the error is simply that it is an invalid toml file, so it's hard to determine what is going wrong.
The library functions should probably panic if the option name is not valid.
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.