Skip to content

Commit

Permalink
custom: custom operation separated
Browse files Browse the repository at this point in the history
  • Loading branch information
ratanphayade committed Jul 13, 2020
1 parent 2fcb624 commit 5474092
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions custom.go
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 5474092

Please sign in to comment.