chore(all): use casers instead of strings.Title

- Add `golang.org/x/text` dependency
- Update code to use `cases.Title(language.English)`
This commit is contained in:
Quentin McGaw
2022-05-27 15:49:41 +00:00
parent bd0868d764
commit 4bde50fb3a
10 changed files with 48 additions and 22 deletions

View File

@@ -1,8 +1,12 @@
package torguard
import "strings"
import (
"strings"
func parseFilename(fileName string) (country, city string) {
"golang.org/x/text/cases"
)
func parseFilename(fileName string, titleCaser cases.Caser) (country, city string) {
const prefix = "TorGuard."
const suffix = ".ovpn"
s := strings.TrimPrefix(fileName, prefix)
@@ -20,7 +24,7 @@ func parseFilename(fileName string) (country, city string) {
s = strings.ReplaceAll(s, "-", " ")
s = strings.ReplaceAll(s, ".", " ")
s = strings.ToLower(s)
s = strings.Title(s)
s = titleCaser.String(s)
city = s
default: