diff --git a/constant/constant.go b/constant/constant.go index c33c282..7c33706 100644 --- a/constant/constant.go +++ b/constant/constant.go @@ -62,6 +62,8 @@ const ( MethodPost = "POST" MethodGet = "GET" + + RetryTimes = 3 ) type Weekday int diff --git a/strings/string.go b/strings/string.go index c4babf1..a0b455f 100644 --- a/strings/string.go +++ b/strings/string.go @@ -7,6 +7,7 @@ import ( "encoding/base64" "encoding/hex" "fmt" + "github.com/shootz-developer/gtool/constant" "math" "math/big" "math/rand" @@ -177,3 +178,13 @@ func Similarity(s1 string, s2 string) float64 { sim := strsim.Compare(s1, s2) return sim } + +// StringFilter 字符串过滤,将1,2,3,4,5 -> '1','2','3','4','5' +func StringFilter(ids string) string { + splitString := strings.Split(ids, constant.Comma) + videos := fmt.Sprintf("'%s'", splitString[0]) + for i := 1; i < len(splitString); i++ { + videos = fmt.Sprintf("%s,'%s'", videos, splitString[i]) + } + return videos +}