2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 23:27:17 +08:00
Files
panel/pkg/str/str.go
2024-03-24 15:55:10 +08:00

33 lines
753 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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)
}