]> Cypherpunks repositories - gostls13.git/commitdiff
bufio: fix emptyFinalToken example to handle multiple Reads
authorAgniva De Sarker <agnivade@yahoo.co.in>
Mon, 14 Jan 2019 08:13:11 +0000 (13:43 +0530)
committerAgniva De Sarker <agniva.quicksilver@gmail.com>
Sat, 2 Mar 2019 18:28:10 +0000 (18:28 +0000)
Fixes #25909

Change-Id: I9a53a1a06aab5d1877a8e9b1b8b782d77d6027a8
Reviewed-on: https://go-review.googlesource.com/c/157758
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/bufio/example_test.go

index 4666e6d985561c565ba95c016cda2149cc00373a..bb5713991805dce5aa54ab626075401e8ce69124 100644 (file)
@@ -94,6 +94,9 @@ func ExampleScanner_emptyFinalToken() {
                                return i + 1, data[:i], nil
                        }
                }
+               if !atEOF {
+                       return 0, nil, nil
+               }
                // There is one final token to be delivered, which may be the empty string.
                // Returning bufio.ErrFinalToken here tells Scan there are no more tokens after this
                // but does not trigger an error to be returned from Scan itself.