|
|
@ -3,6 +3,7 @@ package main |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"fmt" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"unicode" |
|
|
|
|
|
|
|
|
|
|
|
"golang.org/x/text/cases" |
|
|
|
"golang.org/x/text/cases" |
|
|
|
"golang.org/x/text/language" |
|
|
|
"golang.org/x/text/language" |
|
|
@ -112,8 +113,22 @@ func case2Camel(name string) string { |
|
|
|
} |
|
|
|
} |
|
|
|
return enCases.String(name) |
|
|
|
return enCases.String(name) |
|
|
|
} |
|
|
|
} |
|
|
|
name = strings.ToLower(name) |
|
|
|
strs := strings.Split(name, "_") |
|
|
|
name = strings.Replace(name, "_", " ", -1) |
|
|
|
words := make([]string, 0, len(strs)) |
|
|
|
name = enCases.String(name) |
|
|
|
for _, w := range strs { |
|
|
|
return strings.Replace(name, " ", "", -1) |
|
|
|
hasLower := false |
|
|
|
|
|
|
|
for _, r := range w { |
|
|
|
|
|
|
|
if unicode.IsLower(r) { |
|
|
|
|
|
|
|
hasLower = true |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if !hasLower { |
|
|
|
|
|
|
|
w = strings.ToLower(w) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
w = enCases.String(w) |
|
|
|
|
|
|
|
words = append(words, w) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return strings.Join(words, "") |
|
|
|
} |
|
|
|
} |
|
|
|