Fix bug 3

This commit is contained in:
Stephen Weinberg 2010-04-19 20:34:51 -04:00
parent 4cea74d15d
commit 06ccb310d5
2 changed files with 12 additions and 4 deletions

View File

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

13
read.go
View File

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