Feature: Add goctl env (#1557)

This commit is contained in:
anqiansong
2022-02-21 10:19:33 +08:00
committed by GitHub
parent 842656aa90
commit daa98f5a27
18 changed files with 1180 additions and 27 deletions

View File

@@ -6,6 +6,8 @@ import (
"unicode"
)
var WhiteSpace = []rune{'\n', '\t', '\f', '\v', ' '}
// String provides for converting the source text into other spell case,like lower,snake,camel
type String struct {
source string
@@ -114,3 +116,24 @@ func (s String) splitBy(fn func(r rune) bool, remove bool) []string {
}
return list
}
func ContainsAny(s string, runes ...rune) bool {
if len(runes) == 0 {
return true
}
tmp := make(map[rune]struct{}, len(runes))
for _, r := range runes {
tmp[r] = struct{}{}
}
for _, r := range s {
if _, ok := tmp[r]; ok {
return true
}
}
return false
}
func ContainsWhiteSpace(s string) bool {
return ContainsAny(s, WhiteSpace...)
}