parent
3747754236
commit
8aa4e2148c
5 changed files with 61 additions and 3 deletions
strmangle
|
@ -43,6 +43,34 @@ var uppercaseWords = map[string]struct{}{
|
|||
"utf8": {},
|
||||
}
|
||||
|
||||
var reservedWords = map[string]struct{}{
|
||||
"break": {},
|
||||
"case": {},
|
||||
"chan": {},
|
||||
"const": {},
|
||||
"continue": {},
|
||||
"default": {},
|
||||
"defer": {},
|
||||
"else": {},
|
||||
"fallthrough": {},
|
||||
"for": {},
|
||||
"func": {},
|
||||
"go": {},
|
||||
"goto": {},
|
||||
"if": {},
|
||||
"import": {},
|
||||
"interface": {},
|
||||
"map": {},
|
||||
"package": {},
|
||||
"range": {},
|
||||
"return": {},
|
||||
"select": {},
|
||||
"struct": {},
|
||||
"switch": {},
|
||||
"type": {},
|
||||
"var": {},
|
||||
}
|
||||
|
||||
func init() {
|
||||
// Our Boil inflection Ruleset does not include uncountable inflections.
|
||||
// This way, people using words like Sheep will not have
|
||||
|
@ -630,3 +658,12 @@ func IsEnumNormal(values []string) bool {
|
|||
func ShouldTitleCaseEnum(value string) bool {
|
||||
return rgxEnumShouldTitle.MatchString(value)
|
||||
}
|
||||
|
||||
// ReplaceReservedWords takes a word and replaces it with word_ if it's found
|
||||
// in the list of reserved words.
|
||||
func ReplaceReservedWords(word string) string {
|
||||
if _, ok := reservedWords[word]; ok {
|
||||
return word + "_"
|
||||
}
|
||||
return word
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue