summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2016-12-04 18:34:14 +0100
committerSilvan Jegen <s.jegen@gmail.com>2016-12-04 18:34:14 +0100
commit5249fc020067417846bd6cae3f05b6064ddbb1f7 (patch)
treeb6c4f38b7ba8bdd09e5931f8aa9ff9e1d96ac7c4
parent2e420b099775ca52d261b72092ce7e615a7a5847 (diff)
Make the function map more easily changeable
-rw-r--r--manager.go10
1 files 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{},
}