Ver Fonte

add new helpers

AlteredCoder há 5 anos atrás
pai
commit
62daa98bf3
1 ficheiros alterados com 9 adições e 0 exclusões
  1. 9 0
      pkg/exprhelpers/exprlib.go

+ 9 - 0
pkg/exprhelpers/exprlib.go

@@ -2,6 +2,7 @@ package exprhelpers
 
 import (
 	"strconv"
+	"strings"
 
 	log "github.com/sirupsen/logrus"
 )
@@ -15,6 +16,14 @@ func Atof(x string) float64 {
 	return ret
 }
 
+func StartsWith(s string, pref string) bool {
+	return strings.HasPrefix(s, pref)
+}
+
+func EndsWith(s string, suff string) bool {
+	return strings.HasSuffix(s, suff)
+}
+
 func GetExprEnv(ctx map[string]interface{}) map[string]interface{} {
 
 	var ExprLib = map[string]interface{}{"Atof": Atof}