常用函数

字符串分割

1
2
sub := strings.Split(title, " ")//将字符串按空格分割
//"Capitalize The Title"->["Capitalize", "The", "Title"]

字符串拼接

1
2
strings.Join(sub, " ")
//["Capitalize", "The", "Title"]->"Capitalize The Title"

将字符串转为小写

1
2
s = strings.ToLower(s)
//AB->ab

将字符串转为大写

1
2
s = strings.ToUpper(s)
//ab->AB

将字符串首字母转为大写

1
2
s = strings.Title(s)
//ab->Ab