From 54740920b392368552169ceb5955f8b3c5880a83 Mon Sep 17 00:00:00 2001 From: ratanphayade Date: Mon, 13 Jul 2020 14:24:25 +0530 Subject: [PATCH] custom: custom operation separated --- custom.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 custom.go diff --git a/custom.go b/custom.go new file mode 100644 index 0000000..bae18a6 --- /dev/null +++ b/custom.go @@ -0,0 +1,32 @@ +package main + +import "log" + +type callerFunc func(collector, ...string) string + +const ( + CustomCustom = "custom" +) + +var ( + call = map[string]callerFunc{ + CustomCustom: callCustom, + } +) + +func customCall(data collector, tokens []string) string { + if len(tokens) < 1 { + log.Println("error: invalid number of arguments in call") + return "" + } + + if caller, ok := call[tokens[0]]; ok { + return caller(data, tokens[1:]...) + } + + return "" +} + +func callCustom(data collector, tokens ...string) string { + return "this is a custom field" +}