add alert template func str_replace
This commit is contained in:
parent
e2752d6354
commit
fc2d2a586e
|
@ -32,5 +32,6 @@ var genericMap = map[string]interface{}{
|
|||
"div": div,
|
||||
"mul": mul,
|
||||
"lookup": lookup,
|
||||
"str_replace": replace,
|
||||
//"get_keystore_secret": getKeystoreSecret,
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue