Browse Source

Fix bug 3

master
Stephen Weinberg 12 years ago
parent
commit
06ccb310d5
  1. 3
      conf_test.go
  2. 13
      read.go

3
conf_test.go

@ -15,7 +15,8 @@ active = false @@ -15,7 +15,8 @@ active = false
[service-1]
port = 443
url = http://%(host)s/something`
url = http://%(host)s/something
`
type stringtest struct {
section string

13
read.go

@ -49,11 +49,18 @@ func (c *ConfigFile) Read(reader io.Reader) (err os.Error) { @@ -49,11 +49,18 @@ func (c *ConfigFile) Read(reader io.Reader) (err os.Error) {
section = "default"
for {
l, buferr := buf.ReadString('\n') // parse line-by-line
if buferr != nil && buferr != os.EOF {
return err
l = strings.TrimSpace(l)
if buferr != nil {
if buferr != os.EOF {
return err
}
if len(l) == 0 {
break
}
}
l = strings.TrimSpace(l)
// switch written for readability (not performance)
switch {
case len(l) == 0: // empty line

Loading…
Cancel
Save