refactor: simplify the code (#1835)

master
Kevin Wan 3 years ago committed by GitHub
parent 5bcee4cf7c
commit 1a38eddffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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)
} }

Loading…
Cancel
Save