diff options
Diffstat (limited to 'input/stdin.go')
-rw-r--r-- | input/stdin.go | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/input/stdin.go b/input/stdin.go deleted file mode 100644 index 25840ef..0000000 --- a/input/stdin.go +++ /dev/null @@ -1,40 +0,0 @@ -package input - -import ( - "bufio" - "fmt" - "io" - "os" - - "github.com/Shugyousha/stasher/work" -) - -type StdinInput struct { - retchan chan *work.Work -} - -func NewStdin() *StdinInput { - return &StdinInput{} -} - -func (i *StdinInput) Start() chan *work.Work { - i.retchan = make(chan *work.Work, 100) - r := bufio.NewReader(os.Stdin) - - go func() { - for { - bs, err := r.ReadBytes(byte('\n')) - if err == io.EOF { - break - } - if err != nil { - fmt.Printf("Error when reading input from Stdin: %q", err) - os.Exit(1) - } - i.retchan <- &work.Work{Data: bs} - } - close(i.retchan) - }() - - return i.retchan -} |