Code optimized (#493)

This commit is contained in:
kingxt
2021-02-20 19:50:03 +08:00
committed by GitHub
parent 059027bc9d
commit f98c9246b2
28 changed files with 472 additions and 372 deletions

View File

@@ -1,3 +1,5 @@
// Package name provides methods to verify naming style and format naming style
// See the method IsNamingValid, FormatFilename
package name
import (
@@ -6,11 +8,15 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
)
// NamingStyle the type of string
type NamingStyle = string
const (
// NamingLower defines the lower spell case
NamingLower NamingStyle = "lower"
// NamingCamel defines the camel spell case
NamingCamel NamingStyle = "camel"
// NamingSnake defines the snake spell case
NamingSnake NamingStyle = "snake"
)
@@ -29,6 +35,8 @@ func IsNamingValid(namingStyle string) (NamingStyle, bool) {
}
}
// FormatFilename converts the filename string to the target
// naming style by calling method of stringx
func FormatFilename(filename string, style NamingStyle) string {
switch style {
case NamingCamel: