diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2016-12-04 18:34:14 +0100 |
---|---|---|
committer | Silvan Jegen <s.jegen@gmail.com> | 2016-12-04 18:34:14 +0100 |
commit | 5249fc020067417846bd6cae3f05b6064ddbb1f7 (patch) | |
tree | b6c4f38b7ba8bdd09e5931f8aa9ff9e1d96ac7c4 | |
parent | 2e420b099775ca52d261b72092ce7e615a7a5847 (diff) |
Make the function map more easily changeable
-rw-r--r-- | manager.go | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -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{}, } |