refactor: simplify the code (#1835)

This commit is contained in:
Kevin Wan
2022-04-27 10:44:24 +08:00
committed by GitHub
parent 5bcee4cf7c
commit 1a38eddffe

View File

@@ -100,28 +100,23 @@ func format(query string, args ...interface{}) (string, error) {
} }
case '\'', '"', '`': case '\'', '"', '`':
b.WriteByte(ch) b.WriteByte(ch)
for j := i + 1; j < bytes; j++ { for j := i + 1; j < bytes; j++ {
cur := query[j] cur := query[j]
b.WriteByte(cur) b.WriteByte(cur)
switch cur { if cur == '\\' {
case '\\':
j++ j++
if j >= bytes { if j >= bytes {
return "", errUnbalancedEscape return "", errUnbalancedEscape
} }
b.WriteByte(query[j]) b.WriteByte(query[j])
case '\'', '"', '`': } else if cur == ch {
if cur == ch { i = j
i = j break
goto end
}
} }
} }
end:
break
default: default:
b.WriteByte(ch) b.WriteByte(ch)
} }