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 4 "bufio"
5 5 "encoding/json"
6 6 "fmt"
  7 + "io"
7 8 "io/ioutil"
8 9 "log"
9 10 "os"
  11 + "strings"
10 12  
11 13 "fullcycle/analog-kernel/parser"
12 14 )
... ... @@ -82,13 +84,24 @@ func main() {
82 84 check(err)
83 85  
84 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 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 107 // Parse.
... ...