generator: make string function private
Enes Çakır enes@cakir.web.tr
Sun, 08 Mar 2020 15:31:31 +0300
2 files changed,
9 insertions(+),
6 deletions(-)
M
internal/generator/emoji.go
→
internal/generator/emoji.go
@@ -7,7 +7,6 @@ "strconv"
"strings" emojipkg "github.com/enescakir/emoji" - "github.com/enescakir/emoji/internal/strutil" ) var (@@ -114,9 +113,9 @@ e.Constant = c
} func generateConstant(c string) string { - c = strutil.Clean(c) + c = clean(c) c = strings.Title(strings.ToLower(c)) - c = strutil.RemoveSpaces(c) + c = removeSpaces(c) return c }
M
internal/strutil/strutil.go
→
internal/generator/strutil.go
@@ -1,4 +1,4 @@
-package strutil +package main import ( "regexp"@@ -92,7 +92,10 @@ "ŕ": "r",
} ) -func Clean(str string) string { +// clean makes string more cleaner. +// It changes non-latin letters with latin version. +// It removes non–alpha-numeric characters. +func clean(str string) string { for o, n := range changes { str = strings.ReplaceAll(str, o, n) }@@ -102,6 +105,7 @@
return str } -func RemoveSpaces(str string) string { +// removeSpaces removes consecutive whitespaces. +func removeSpaces(str string) string { return whitespaceRegex.ReplaceAllString(str, "") }