From 84ff81302c6600d85411b54e1c76df60e941c1e9 Mon Sep 17 00:00:00 2001 From: susji Date: Thu, 4 Apr 2024 00:17:01 +0300 Subject: [PATCH] Forgot how `bufio.Scanner` works --- main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index f09f835..a40dc09 100644 --- a/main.go +++ b/main.go @@ -39,10 +39,6 @@ func main() { s := bufio.NewScanner(os.Stdin) fmt.Fprintln(os.Stderr, "reading standard input as", mode) for s.Scan() { - if err := s.Err(); err != nil { - fmt.Fprintln(os.Stderr, "reading input failed:", err) - continue // Maybe depart? - } d, err := dec(s.Bytes()) if err != nil { fmt.Fprintln(os.Stderr, "decoding input failed:", err) @@ -60,4 +56,7 @@ func main() { } fmt.Println(string(out)) } + if err := s.Err(); err != nil { + fmt.Fprintln(os.Stderr, "reading input failed:", err) + } }