diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2017-01-20 21:03:08 +0100 |
---|---|---|
committer | Silvan Jegen <s.jegen@gmail.com> | 2017-01-20 21:03:08 +0100 |
commit | 5c24009f2b1fd5a7e5abd4dc33ebdec0c6eaaf25 (patch) | |
tree | 7447a384efe6a5b45106fde621e53bdf38ad608a /input/stdin.go | |
parent | ba15251035961020363fa5aff95ff0a361023af9 (diff) |
Introduce registry
We introduce a registry that contains maps to builder functions. These
builder functions return the interface implementation of the modules
specified in the configuration.
We also make the input module type use the registry. All other module
types still have to be converted.
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 -} |