utils

package
v1.0.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (
	StyleSmallCamelCase = "smallCamelCase"
	StyleCamelCase      = "camelCase"
	StyleSnakeCase      = "snakeCase"
	StyleKebab          = "kebab"
)

Variables

This section is empty.

Functions

func CamelCase

func CamelCase(s string) string

CamelCase returns the CamelCased name. If there is an interior underscore followed by a lower case letter, drop the underscore and convert the letter to upper case. There is a remote possibility of this rewrite causing a name collision, but it's so remote we're prepared to pretend it's nonexistent - since the C++ generator lowercases names, it's extremely unlikely to have two fields with different capitalizations. In short, _my_field_name_2 becomes XMyFieldName_2.

func GetPkgName

func GetPkgName(path string) string

PkgName returns the package name from a filepath with a package qualifier. ./model -> model

func JoinCase

func JoinCase(s string, delimiter byte) string

func Kebab

func Kebab(str string) string

Kebab 转换驼峰字符串为用'-'分隔的字符串 example2: delimiter = '-' initialisms = DefaultInitialisms IdCom -> id-com Idcom -> idcom nameIdCom -> name-id-com nameIdcom -> name-idcom

func LowTitle

func LowTitle(s string) string

LowTitle 首字母小写 see strings.Title

func PkgName

func PkgName(path string) string

PkgName returns the package name from a Go path with a package qualifier. github.com/things/ens -> ens

func PkgQualifier

func PkgQualifier(ident string) string

PkgQualifier returns the package name from a Go identifier with a package qualifier. eg. time.Time -> time

func SmallCamelCase

func SmallCamelCase(fieldName string) string

SmallCamelCase to small camel case string id_com -> idCom idcom -> idcom name_id_com -> nameIdCom name_idcom -> nameIdcom

func SnakeCase

func SnakeCase(str string) string

SnakeCase 转换驼峰字符串为用'_'分隔的字符串 example2: delimiter = '_' initialisms = DefaultInitialisms IdCom -> id_com Idcom -> idcom nameIdCom -> name_id_com nameIdcom -> name_idcom

func SplitCase

func SplitCase(str string, delimiter byte) string

SplitCase 转换驼峰字符串为用delimiter分隔的字符串 example: delimiter = '_' 空字符 -> 空字符 HelloWorld -> hello_world Hello_World -> hello_world HiHello_World -> hi_hello_world IdCom -> id_com Idcom -> idcom nameIdCom -> name_id_com nameIdcom -> name_idcom

func StyleName

func StyleName(kind, name string) string

func TrimFieldComment

func TrimFieldComment(s string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL