Skip to content

Commit

Permalink
replace strings.Cut with Split
Browse files Browse the repository at this point in the history
  • Loading branch information
yuryfirebolt committed Aug 8, 2022
1 parent c2fb0a5 commit 2e053fd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ func parseSetStatement(query string) (string, string, error) {
query = strings.TrimSpace(query)
if strings.HasPrefix(strings.ToUpper(query), "SET") {
query = strings.TrimSpace(query[len("SET"):])
key, value, found := strings.Cut(query, "=")
if !found {
values := strings.Split(query, "=")
if len(values) < 2 {
return "", "", fmt.Errorf("not a valid set statement, didn't find '=' sign")
}
key = strings.TrimSpace(key)
value = strings.TrimSpace(value)
key := strings.TrimSpace(values[0])
value := strings.TrimSpace(values[1])
if key != "" && value != "" {
return key, value, nil
}
Expand Down

0 comments on commit 2e053fd

Please sign in to comment.