aboutsummaryrefslogtreecommitdiff
path: root/src/bufio/scan.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/bufio/scan.go')
-rw-r--r--src/bufio/scan.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bufio/scan.go b/src/bufio/scan.go
index c5714f331e..a41451524d 100644
--- a/src/bufio/scan.go
+++ b/src/bufio/scan.go
@@ -112,7 +112,9 @@ func (s *Scanner) Scan() bool {
// Loop until we have a token.
for {
// See if we can get a token with what we already have.
- if s.end > s.start {
+ // If we've run out of data but have an error, give the split function
+ // a chance to recover any remaining, possibly empty token.
+ if s.end > s.start || s.err != nil {
advance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)
if err != nil {
s.setErr(err)