Code optimized (#523)

* optimized markdown generator

* optimized markdown generator

* optimized markdown generator

* add more comment

* add comment

* add comment

* add comments for rpc tool

* add comments for model tool

* add comments for model tool

* add comments for model tool

* add comments for config tool

* add comments for config tool

* add comments

* add comments

* add comments

* add comments

* add comment

* remove rpc main head info

* add comment

* optimized

Co-authored-by: anqiansong <anqiansong@xiaoheiban.cn>
This commit is contained in:
kingxt
2021-02-26 16:11:47 +08:00
committed by GitHub
parent ef146cf5ba
commit e6ef1fca12
104 changed files with 651 additions and 375 deletions

View File

@@ -5,6 +5,7 @@ import (
"unicode"
)
// IsUpperCase returns true if the rune in A-Z
func IsUpperCase(r rune) bool {
if r >= 'A' && r <= 'Z' {
return true
@@ -12,6 +13,7 @@ func IsUpperCase(r rune) bool {
return false
}
// IsLowerCase returns true if the rune in a-z
func IsLowerCase(r rune) bool {
if r >= 'a' && r <= 'z' {
return true
@@ -19,6 +21,7 @@ func IsLowerCase(r rune) bool {
return false
}
// ToSnakeCase returns a copy string by converting camel case into snake case
func ToSnakeCase(s string) string {
var out []rune
for index, r := range s {
@@ -44,6 +47,7 @@ func ToSnakeCase(s string) string {
return string(out)
}
// ToCamelCase returns a copy string by converting snake case into camel case
func ToCamelCase(s string) string {
s = ToLower(s)
out := []rune{}
@@ -66,6 +70,7 @@ func ToCamelCase(s string) string {
return string(out)
}
// ToLowerCase converts rune into lower case
func ToLowerCase(r rune) rune {
dx := 'A' - 'a'
if IsUpperCase(r) {
@@ -73,6 +78,8 @@ func ToLowerCase(r rune) rune {
}
return r
}
// ToUpperCase converts rune into upper case
func ToUpperCase(r rune) rune {
dx := 'A' - 'a'
if IsLowerCase(r) {
@@ -81,6 +88,7 @@ func ToUpperCase(r rune) rune {
return r
}
// ToLower returns a copy string by converting it into lower
func ToLower(s string) string {
var out []rune
for _, r := range s {
@@ -89,6 +97,7 @@ func ToLower(s string) string {
return string(out)
}
// ToUpper returns a copy string by converting it into upper
func ToUpper(s string) string {
var out []rune
for _, r := range s {
@@ -97,13 +106,7 @@ func ToUpper(s string) string {
return string(out)
}
func LowerFirst(s string) string {
if len(s) == 0 {
return s
}
return ToLower(s[:1]) + s[1:]
}
// UpperFirst converts s[0] into upper case
func UpperFirst(s string) string {
if len(s) == 0 {
return s
@@ -111,6 +114,7 @@ func UpperFirst(s string) string {
return ToUpper(s[:1]) + s[1:]
}
// UnExport converts the first letter into lower case
func UnExport(text string) bool {
var flag bool
str := strings.Map(func(r rune) rune {