add alert template func str_replace

This commit is contained in:
liugq 2023-08-07 21:03:14 +08:00
parent e2752d6354
commit fc2d2a586e
2 changed files with 21 additions and 0 deletions

View File

@ -32,5 +32,6 @@ var genericMap = map[string]interface{}{
"div": div, "div": div,
"mul": mul, "mul": mul,
"lookup": lookup, "lookup": lookup,
"str_replace": replace,
//"get_keystore_secret": getKeystoreSecret, //"get_keystore_secret": getKeystoreSecret,
} }

View File

@ -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)
}