fix buildfile/reader to read last line (without NEWLINE)

This commit is contained in:
Adrien Marquès 2018-11-14 09:58:51 +01:00
parent 361c3f6c25
commit 7e8b45d750
1 changed files with 10 additions and 1 deletions

View File

@ -37,13 +37,22 @@ func NewReader(ctx *instruction.ExecutionContext, buildfile io.Reader) (*Reader,
// add each line as instruction // add each line as instruction
l, reader := 0, bufio.NewReader(buildfile) l, reader := 0, bufio.NewReader(buildfile)
eof := false
for { for {
if eof {
break
}
l++ l++
// read line until end // read line until end
line, err := reader.ReadString('\n') line, err := reader.ReadString('\n')
if err == io.EOF { if err == io.EOF {
break if len(line) > 0 {
eof = true
} else {
break
}
} else if err != nil { } else if err != nil {
return nil, LineError{l, err} return nil, LineError{l, err}
} }