all repos — emoji @ 84a0a67371e0847129343a1165bdd41e95f5b49d

A minimalistic emoji package for Go (golang)

generator: make string function private
Enes Çakır enes@cakir.web.tr
Sun, 08 Mar 2020 15:31:31 +0300
commit

84a0a67371e0847129343a1165bdd41e95f5b49d

parent

f33b109b13e8375d8b2da4df81c7a339d2963fea

2 files changed, 9 insertions(+), 6 deletions(-)

jump to
M internal/generator/emoji.gointernal/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.gointernal/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, "") }