github.com/easysoft/zendata@v0.0.0-20240513203326-705bd5a7fd67/internal/pkg/helper/token.go (about) 1 package helper 2 3 import ( 4 "regexp" 5 "strings" 6 7 uuid "github.com/satori/go.uuid" 8 ) 9 10 func GenerateToken(format string) (ret string) { 11 ret = uuid.NewV4().String() 12 sep := "" 13 14 regx := regexp.MustCompile(`token\(\s*(\S+)\s*\)`) 15 arr := regx.FindStringSubmatch(format) 16 if len(arr) > 1 { 17 sep = strings.Trim(arr[1], "'") 18 } 19 20 ret = strings.ReplaceAll(ret, "-", sep) 21 22 return 23 }