diff --git a/service/alerting/funcs/function.go b/service/alerting/funcs/function.go index 881344a8..37978fa9 100644 --- a/service/alerting/funcs/function.go +++ b/service/alerting/funcs/function.go @@ -32,5 +32,6 @@ var genericMap = map[string]interface{}{ "div": div, "mul": mul, "lookup": lookup, + "str_replace": replace, //"get_keystore_secret": getKeystoreSecret, } diff --git a/service/alerting/funcs/strings.go b/service/alerting/funcs/strings.go new file mode 100644 index 00000000..86a25bbe --- /dev/null +++ b/service/alerting/funcs/strings.go @@ -0,0 +1,20 @@ +/* Copyright © INFINI Ltd. All rights reserved. + * web: https://infinilabs.com + * mail: hello#infini.ltd */ + +package funcs + +import "strings" + +func substring(start, end int, s string) string { + runes := []rune(s) + length := len(runes) + if start < 0 || start > length || end < 0 || end > length{ + return s + } + return string(runes[start:end]) +} + +func replace(old, new, src string) string { + return strings.Replace(src, old, new, -1) +} \ No newline at end of file