Skip to content

bufio: Missed last line when read file by bufio.NewScanner(f).Scan() #21063

@AJIOB

Description

@AJIOB

What version of Go are you using (go version)?

go version go1.8.3 windows/amd64

What operating system and processor architecture are you using (go env)?

Windows 10 Pro x64 version 1703 (OS build 15063.483)

What did you do?

Code: https://play.golang.org/p/PlxIOWk271
It is a simple example dup3 from Kernighan Go book. I'm passing arguments one.txt and two.txt (files from archieve One version.zip) and gets such output:
2 Hello
Run command: go run main.go one.txt two.txt

But when I'm addnig simple '\n' escape sequence symbol (Version two.zip) in file one.txt, I'm getting such output:
2 Hello
2 me

Why didi I loose last line of file one.txt by reading by Scan() and Text() functions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions