Minor cleanup.

This commit is contained in:
Alec Thomas
2018-06-27 21:13:47 +10:00
parent 1bb0c0b4b2
commit 0bc26a865d
2 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ func camelCase(src string) (entries []string) {
// split into fields based on class of unicode character // split into fields based on class of unicode character
for _, r := range src { for _, r := range src {
var class int var class int
switch true { switch {
case unicode.IsLower(r): case unicode.IsLower(r):
class = 1 class = 1
case unicode.IsUpper(r): case unicode.IsUpper(r):
+5 -4
View File
@@ -383,16 +383,17 @@ func SplitEscaped(s string, sep rune) (out []string) {
escaped := false escaped := false
token := "" token := ""
for _, ch := range s { for _, ch := range s {
if escaped { switch {
case escaped:
token += string(ch) token += string(ch)
escaped = false escaped = false
} else if ch == '\\' { case ch == '\\':
escaped = true escaped = true
} else if ch == sep && !escaped { case ch == sep && !escaped:
out = append(out, token) out = append(out, token)
token = "" token = ""
escaped = false escaped = false
} else { default:
token += string(ch) token += string(ch)
} }
} }