utils

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CamelCase

func CamelCase(s string, enableLint bool) string

CamelCase to camel case string id_com -> IDCom idcom -> Idcom name_id_com -> NameIDCom name_idcom -> NameIdcom

func GetPkgName

func GetPkgName(path string) string

func IsExist

func IsExist(paths string) bool

IsExist checks whether a file or directory exists. It returns false when the file or directory does not exist.

func Kebab

func Kebab(str string, enableLint bool) string

Kebab 转换驼峰字符串为用'-'分隔的字符串,特殊字符由DefaultInitialisms决定取代 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 Recombine

func Recombine(str string, delimiter byte, enableLint bool) string

Recombine 转换驼峰字符串为用delimiter分隔的字符串, 特殊字符由DefaultInitialisms决定取代 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 SmallCamelCase

func SmallCamelCase(fieldName string, enableLint bool) 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, enableLint bool) string

SnakeCase 转换驼峰字符串为用'_'分隔的字符串,特殊字符由DefaultInitialisms决定取代 example2: delimiter = '_' initialisms = DefaultInitialisms IDCom -> id_com IDcom -> idcom nameIDCom -> name_id_com nameIDcom -> name_idcom

func UnRecombine

func UnRecombine(str string, delimiter byte, enableLint bool) string

UnRecombine 转换sep分隔的字符串为驼峰字符串 example: delimiter = '_' 空字符 -> 空字符 hello_world -> HelloWorld

func WorkDir

func WorkDir() string

WorkDir 获取当前工作目录

func WriteFile

func WriteFile(filename string, data []byte) error

WriteFile writes data to a file named by filename. If the file does not exist, WriteFile creates it and its upper level paths.

func WriteFileWithTemplate added in v0.3.0

func WriteFileWithTemplate(filename string, t *template.Template, data any) error

WriteFileWithTemplate write file with template.

Types

This section is empty.

Jump to

Keyboard shortcuts

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