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]
port = 443
url = http://%(host)s/something`
url = http://%(host)s/something
`
type stringtest struct {
section string

11
read.go
View File

@ -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 {
l = strings.TrimSpace(l)
if buferr != nil {
if buferr != os.EOF {
return err
}
l = strings.TrimSpace(l)
if len(l) == 0 {
break
}
}
// switch written for readability (not performance)
switch {
case len(l) == 0: // empty line