From ca201089971dd4d5c89b33a2eb53adf73ff746a0 Mon Sep 17 00:00:00 2001 From: abdullah-alaadine Date: Sat, 8 Jul 2023 00:39:32 +0300 Subject: [PATCH 1/2] add 'golang.org/x/text/cases' --- go.mod | 1 + go.sum | 2 ++ 2 files changed, 3 insertions(+) diff --git a/go.mod b/go.mod index 74f4548..a96f0d2 100644 --- a/go.mod +++ b/go.mod @@ -14,4 +14,5 @@ require ( github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect golang.org/x/sys v0.6.0 // indirect golang.org/x/term v0.1.0 // indirect + golang.org/x/text v0.11.0 // indirect ) diff --git a/go.sum b/go.sum index 9466a65..671d7db 100644 --- a/go.sum +++ b/go.sum @@ -32,5 +32,7 @@ golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.1.0 h1:g6Z6vPFA9dYBAF7DWcH6sCcOntplXsDKcliusYijMlw= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 84725816a5e138aad19e5f2a2d7d49072f914eb3 Mon Sep 17 00:00:00 2001 From: abdullah-alaadine Date: Sat, 8 Jul 2023 00:40:18 +0300 Subject: [PATCH 2/2] use 'caser.String' instead of the deprecated 'strings.Title' --- munge.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/munge.go b/munge.go index e563abc..4beaeff 100644 --- a/munge.go +++ b/munge.go @@ -6,6 +6,8 @@ import ( "strings" "github.com/gookit/color" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) var tmpWordList []string @@ -100,13 +102,14 @@ func removeDuplication(arr []string) []string { } func munge(wrd string, level int) { + caser := cases.Title(language.English) if level > 0 { tmpWordList = append(tmpWordList, wrd) tmpWordList = append(tmpWordList, strings.ToUpper(wrd)) - tmpWordList = append(tmpWordList, strings.Title(wrd)) + tmpWordList = append(tmpWordList, caser.String(wrd)) } if level > 2 { - temp := strings.Title(wrd) + temp := caser.String(wrd) tmpWordList = append(tmpWordList, strings.ToLower(temp)) } if level > 4 {