Documentation
¶
Index ¶
- Variables
- func Append(strs []string, str string) []string
- func Bytes2Str(b []byte) string
- func CamelCase(str string) string
- func Compare(s1, s2 []string) bool
- func CompareU(s1, s2 []string) bool
- func Contains(sl []string, str string) bool
- func ContainsFold(sl []string, str string) bool
- func Delete(s []string, e string) []string
- func DeleteAll(s []string, e string) []string
- func LowTitle(str string) string
- func Recombine(str string, sep byte) string
- func Reverse(s string) string
- func SnakeCase(str string) string
- func Str2Bytes(str string) []byte
- func UnRecombine(str string, sep byte) string
- func Unique(a []string) []string
- type Recode
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultInitialisms default initialism for snake case DefaultInitialisms = []string{ "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "LHS", "QPS", "RAM", "RHS", "RPC", "SLA", "SMTP", "SSH", "TLS", "TTL", "UID", "UI", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XSRF", "XSS", } )
Functions ¶
func Bytes2Str ¶
Bytes2Str Zero-copy convert from byte slice to a string see reflect.SliceHeader and reflect.StringHeader 理论上是 string(byte{"a","b"}) 的20倍速率
func CamelCase ¶
CamelCase to camel case string id_com -> IdCom idcom -> Idcom name_id_com -> NameIdCom name_idcom -> NameIdcom
func Compare ¶
Compare compares two 'string' type slices. It returns true if elements and order are both the same. 比较两个字符串切片,要求元素和顺序都一致才返回true
func CompareU ¶
CompareU compares two 'string' type slices. It returns true if elements are the same, and ignores the order. 比较两个字符串切片,要求元素一致,且忽略顺序,一致返回true
func ContainsFold ¶
ContainsFold returns true if the string exists in given slice, ignore case. 字符串切片是否含有指定的元素,忽略大小写
func Recombine ¶
Recombine 转换驼峰字符串为用sep分隔的字符串 example: sep = '_' HelloWorld -> hello_world Hello_World -> hello_world HiHello_World -> hi_hello_world IDCom -> id_com IDcom -> i_dcom nameIDCom -> name_id_com nameIDcom -> name_i_dcom
func SnakeCase ¶
SnakeCase 转换驼峰字符串为用'_'分隔的字符串,特殊字符由DefaultInitialisms决定取代 example2: sep = '_' initialisms = DefaultInitialisms IDCom -> id_com IDcom -> idcom nameIDCom -> name_id_com nameIDcom -> name_idcom
func Str2Bytes ¶
Str2Bytes Convert different types to byte slice using types and functions in unsafe and reflect package(see reflect.SliceHeader and reflect.StringHeader). It has higher performance, but notice that it may be not safe when garbage collection happens.Use it when you need to temporary convert a long string to a byte slice and won't keep it for long time. 理论上与 []byte("string") 速度几乎是一致的
func UnRecombine ¶
UnRecombine 转换sep分隔的字符串为驼峰字符串 example: sep = '_' hello_world -> HelloWorld
Types ¶
type Recode ¶
type Recode struct {
// contains filtered or unexported fields
}
Recode 重组转换一些特殊的字符