mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 22:07:16 +08:00
33 lines
753 B
Go
33 lines
753 B
Go
// Package str 字符串辅助方法
|
||
package str
|
||
|
||
import (
|
||
"github.com/gertd/go-pluralize"
|
||
"github.com/iancoleman/strcase"
|
||
)
|
||
|
||
// Plural 转为复数 user -> users
|
||
func Plural(word string) string {
|
||
return pluralize.NewClient().Plural(word)
|
||
}
|
||
|
||
// Singular 转为单数 users -> user
|
||
func Singular(word string) string {
|
||
return pluralize.NewClient().Singular(word)
|
||
}
|
||
|
||
// Snake 转为 snake_case,如 TopicComment -> topic_comment
|
||
func Snake(s string) string {
|
||
return strcase.ToSnake(s)
|
||
}
|
||
|
||
// Camel 转为 CamelCase,如 topic_comment -> TopicComment
|
||
func Camel(s string) string {
|
||
return strcase.ToCamel(s)
|
||
}
|
||
|
||
// LowerCamel 转为 lowerCamelCase,如 TopicComment -> topicComment
|
||
func LowerCamel(s string) string {
|
||
return strcase.ToLowerCamel(s)
|
||
}
|