package main import ( "fmt" "sync" "github.com/Shugyousha/stasher/filter" "github.com/Shugyousha/stasher/input" "github.com/Shugyousha/stasher/output" "github.com/Shugyousha/stasher/work" ) type Manager struct { Input input.Input Filter filter.Filter Output output.Output } func (m *Manager) Run() { var wg sync.WaitGroup ic := m.Input.Start() for w := range ic { wg.Add(1) go func(w *work.Work) { nw := m.Filter.Filter(w) err := nw.Error() if err != nil { fmt.Printf("Got an error when processing Work: %q\n", err) } m.Output.Output(nw) wg.Done() }(w) } wg.Wait() }