Commit 6db1fd78170b052699775dae98ad8f0df2468a8c

Authored by 김태훈
1 parent 2b591388ff
Exists in master

EOF 무시하도록 변경

Showing 1 changed file with 18 additions and 5 deletions   Show diff stats
go/src/fullcycle/analog-kernel/main.go
@@ -4,9 +4,11 @@ import ( @@ -4,9 +4,11 @@ import (
4 "bufio" 4 "bufio"
5 "encoding/json" 5 "encoding/json"
6 "fmt" 6 "fmt"
  7 + "io"
7 "io/ioutil" 8 "io/ioutil"
8 "log" 9 "log"
9 "os" 10 "os"
  11 + "strings"
10 12
11 "fullcycle/analog-kernel/parser" 13 "fullcycle/analog-kernel/parser"
12 ) 14 )
@@ -82,13 +84,24 @@ func main() { @@ -82,13 +84,24 @@ func main() {
82 check(err) 84 check(err)
83 85
84 // Read stdin. 86 // Read stdin.
85 - s := bufio.NewScanner(os.Stdin)  
86 - for s.Scan() {  
87 - if l := s.Text(); l == "end of kernel" { 87 + stdin := bufio.NewReader(os.Stdin)
  88 + for {
  89 + s, err := stdin.ReadString('\n')
  90 + if err != nil {
  91 + if err != io.EOF {
  92 + log.Fatal(err)
  93 + break
  94 + }
  95 +
  96 + continue
  97 + }
  98 +
  99 + s = strings.Trim(s, "\r\n")
  100 + if s == "end of kernel" {
88 break 101 break
89 - } else {  
90 - r.Log = append(r.Log, l)  
91 } 102 }
  103 +
  104 + r.Log = append(r.Log, s)
92 } 105 }
93 106
94 // Parse. 107 // Parse.