qinwenshi / goconf

Automatically exported from code.google.com/p/goconf
0 stars 0 forks source link

GetError when nothing defined on a section #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Not exactly an issue, more of a feature request.

In the usage example on the main page you've got:

## config file
[default]
host = something.com
port = 443
active = true
compression = off

[service-1]
compression = on

[service-2]
port = 444

## go program
c, err := conf.ReadConfigFile("something.config")
c.GetBool("default", "compression") // returns false
c.GetBool("service-1", "compression") // returns true
c.GetBool("service-2", "compression") // returns GetError

###

I don't think there's really a point in knowing if a setting comes from the 
default section or not so IMHO it would be nicer if c.GetBool("service-2", 
"compression") returned the relevant setting from the "default" section - it 
feels like it would make the code based on this package more elegant.

Original issue reported on code.google.com by isza...@gmail.com on 27 Jun 2010 at 12:15

GoogleCodeExporter commented 9 years ago
I disagree.

The example uses a default section, with other sections that override it. This 
isn't always the case. I think a config library shouldn't assume that it may 
use settings from a section, even if it's named "default".

Original comment by v...@demuzere.be on 4 Sep 2012 at 4:34

GoogleCodeExporter commented 9 years ago
I think this is just the behavior of the Python package, and maybe other 
languages, and so maybe should be expected here: when a "default" section is 
defined it is used as fallback for others.

Original comment by rodrigo.moraes on 4 Sep 2012 at 4:46