From 6db1fd78170b052699775dae98ad8f0df2468a8c Mon Sep 17 00:00:00 2001 From: victor Date: Thu, 14 Mar 2019 10:52:01 +0900 Subject: [PATCH] =?UTF-8?q?EOF=20=EB=AC=B4=EC=8B=9C=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go/src/fullcycle/analog-kernel/main.go | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/go/src/fullcycle/analog-kernel/main.go b/go/src/fullcycle/analog-kernel/main.go index c7400c5..ecb5ae4 100644 --- a/go/src/fullcycle/analog-kernel/main.go +++ b/go/src/fullcycle/analog-kernel/main.go @@ -4,9 +4,11 @@ import ( "bufio" "encoding/json" "fmt" + "io" "io/ioutil" "log" "os" + "strings" "fullcycle/analog-kernel/parser" ) @@ -82,13 +84,24 @@ func main() { check(err) // Read stdin. - s := bufio.NewScanner(os.Stdin) - for s.Scan() { - if l := s.Text(); l == "end of kernel" { + stdin := bufio.NewReader(os.Stdin) + for { + s, err := stdin.ReadString('\n') + if err != nil { + if err != io.EOF { + log.Fatal(err) + break + } + + continue + } + + s = strings.Trim(s, "\r\n") + if s == "end of kernel" { break - } else { - r.Log = append(r.Log, l) } + + r.Log = append(r.Log, s) } // Parse. -- 2.1.4