1 Star 0 Fork 0

庞飞 / multiapp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
strs.go 1.59 KB
一键复制 编辑 原始数据 按行查看 历史
庞飞 提交于 2023-10-08 10:52 . 去除uuid方法
package strs
import (
"strings"
"unicode"
)
/*
IsBlank checks if a string is whitespace or empty (""). Observe the following behavior:
goutils.IsBlank("") = true
goutils.IsBlank(" ") = true
goutils.IsBlank("bob") = false
goutils.IsBlank(" bob ") = false
Parameter:
str - the string to check
Returns:
true - if the string is whitespace or empty ("")
*/
func IsBlank(str string) bool {
strLen := len(str)
if str == "" || strLen == 0 {
return true
}
for i := 0; i < strLen; i++ {
if unicode.IsSpace(rune(str[i])) == false {
return false
}
}
return true
}
func IsNotBlank(str string) bool {
return !IsBlank(str)
}
func IsAnyBlank(strs ...string) bool {
for _, str := range strs {
if IsBlank(str) {
return true
}
}
return false
}
func DefaultIfBlank(str, def string) string {
if IsBlank(str) {
return def
} else {
return str
}
}
// IsEmpty checks if a string is empty (""). Returns true if empty, and false otherwise.
func IsEmpty(str string) bool {
return len(str) == 0
}
func IsNotEmpty(str string) bool {
return !IsEmpty(str)
}
func Substr(s string, start, length int) string {
bt := []rune(s)
if start < 0 {
start = 0
}
if start > len(bt) {
start = start % len(bt)
}
var end int
if (start + length) > (len(bt) - 1) {
end = len(bt)
} else {
end = start + length
}
return string(bt[start:end])
}
func Equals(a, b string) bool {
return a == b
}
func EqualsIgnoreCase(a, b string) bool {
return a == b || strings.ToUpper(a) == strings.ToUpper(b)
}
// RuneLen 字符成长度
func RuneLen(s string) int {
bt := []rune(s)
return len(bt)
}
Go
1
https://gitee.com/pangxianfei/multiapp.git
git@gitee.com:pangxianfei/multiapp.git
pangxianfei
multiapp
multiapp
v1.2.3

搜索帮助

53164aa7 5694891 3bd8fe86 5694891