diff --git a/function/function.go b/function/function.go index 3356c6d..85fc6e9 100644 --- a/function/function.go +++ b/function/function.go @@ -58,6 +58,15 @@ func Regist(name string, fn Func) error { return nil } +// Registered returns all registered functions or operators +func Registered() []string { + ss := make([]string, 0, len(functions)) + for k, _ := range functions { + ss = append(ss, k) + } + return ss +} + // MustRegist is same as Regist but may overide if function with name existed func MustRegist(name string, fn Func) { functions[name] = fn diff --git a/function/function_test.go b/function/function_test.go index 35728a6..d1a2146 100644 --- a/function/function_test.go +++ b/function/function_test.go @@ -1,6 +1,8 @@ package function -import "testing" +import ( + "testing" +) func TestGet(t *testing.T) { if err := Regist("foo", foo); err != nil { @@ -23,7 +25,7 @@ func TestGet(t *testing.T) { if _, err := Get("fooooo"); err != ErrNotFound { t.Error("should not found") } - + _ = Registered() } var foo = func(params ...interface{}) (interface{}, error) {