Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Fix bug parsing config files without a trailing newline.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeady committed Jun 1, 2013
1 parent f465667 commit 3883198
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion configfile.go
Expand Up @@ -211,7 +211,9 @@ func (c *ConfigFile) read(buf *bufio.Reader) error {
for {
l, err := buf.ReadString('\n') // parse line-by-line
if err == io.EOF {
break
if len(l) == 0 {
break
}
} else if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion configfile_test.go
Expand Up @@ -178,7 +178,7 @@ func TestReadFile(t *testing.T) {
buf.WriteString("[secTION-2]\n")
buf.WriteString("IS-flag-TRUE=Yes\n")
buf.WriteString("[section-1]\n") // continue again [section-1]
buf.WriteString("option4=this_is_%(variable2)s.\n")
buf.WriteString("option4=this_is_%(variable2)s.")
buf.Flush()
file.Close()

Expand Down

0 comments on commit 3883198

Please sign in to comment.