1 Star 0 Fork 0

tech4good/common

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
string.go 662 Bytes
一键复制 编辑 原始数据 按行查看 历史
v_chaoni 提交于 2021-11-12 17:06 +08:00 . 1
package utils
import (
"github.com/google/uuid"
"strings"
)
// GetUUID 获取guid
func GetUUID() string {
struuid := uuid.New().String()
return strings.Replace(struuid, "-", "", -1)
}
// Split 支持多sep的字符串分割,简单使用递归,所以seps的个数不能超过50个
func Split(s string, seps ...string) []string {
if len(seps) == 0 || len(seps[0]) == 0 {
return []string{s}
}
if len(seps) == 1 {
return strings.Split(s, seps[0])
}
curSep := seps[0]
nextSeps := seps[1:]
tRes := strings.Split(s, curSep)
res := []string{}
for _, item := range tRes {
r := Split(item, nextSeps...)
res = append(res, r...)
}
return res
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tech4good/common.git
git@gitee.com:tech4good/common.git
tech4good
common
common
v1.0.2

搜索帮助