1 Star 0 Fork 0

goeoeo/cycmd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
word.go 950 Bytes
一键复制 编辑 原始数据 按行查看 历史
chenyu 提交于 2021-08-07 22:03 +08:00 . word 工具
package word
import (
"strings"
"unicode"
)
func ToUpper(s string) string {
return strings.ToUpper(s)
}
func ToLower(s string) string {
return strings.ToLower(s)
}
//UnderscoreToUpperCamelCase 下划线转大写驼峰.
func UnderscoreToUpperCamelCase(s string) string {
s = strings.Replace(s, "_", " ", -1)
s = strings.Title(s)
return strings.Replace(s, " ", "", -1)
}
//UnderscoreToLowerCamelCase 下线线转小写驼峰.
func UnderscoreToLowerCamelCase(s string) string {
if s == "" {
return ""
}
s = UnderscoreToUpperCamelCase(s)
return string(unicode.ToLower(rune(s[0]))) + s[1:]
}
//CamelCaseToUnderscore 驼峰转下划线.
func CamelCaseToUnderscore(s string) string {
var output []rune
for i, r := range s {
if i == 0 {
output = append(output, unicode.ToLower(r))
continue
}
if unicode.IsUpper(r) {
output = append(output, '_')
}
output = append(output, unicode.ToLower(r))
}
return string(output)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/goeoeo/cycmd.git
git@gitee.com:goeoeo/cycmd.git
goeoeo
cycmd
cycmd
db9a10692ab2

搜索帮助