From 5249fc020067417846bd6cae3f05b6064ddbb1f7 Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Sun, 4 Dec 2016 18:34:14 +0100 Subject: Make the function map more easily changeable --- manager.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/manager.go b/manager.go index 3253129..10de4ef 100644 --- a/manager.go +++ b/manager.go @@ -69,11 +69,6 @@ func (i *StdinInput) Start() chan *Work { } func (f *StringFilter) Filter(w *Work) *Work { - if f.FilterFuncMap == nil { - f.FilterFuncMap = make(map[string]func(string) string, 10) - f.FilterFuncMap["F"] = func(s string) string { return strings.ToUpper(s) } - } - dec := json.NewDecoder(bytes.NewReader(w.data)) jm := make(map[string]string, 10) @@ -134,9 +129,12 @@ func (m *Manager) Run() { } func main() { + ffmap := make(map[string]func(string) string, 10) + ffmap["F"] = func(s string) string { return strings.ToUpper(s) } + m := Manager{ Input: &StdinInput{}, - Filter: &StringFilter{}, + Filter: &StringFilter{FilterFuncMap: ffmap}, Output: &StdoutOutput{}, } -- cgit v1.2.3