refactor: replace strings.Replace with strings.ReplaceAll (#15392)

strings.ReplaceAll(s, old, new) is a wrapper function for
strings.Replace(s, old, new, -1). But strings.ReplaceAll is more
readable and removes the hardcoded -1.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
Eng Zer Jun
2022-08-04 03:22:48 +08:00
committed by GitHub
parent 475a88e813
commit 6141d61839
36 changed files with 56 additions and 56 deletions

View File

@@ -16,7 +16,7 @@ import (
const (
defaultMysqlRevocationStmts = `
REVOKE ALL PRIVILEGES, GRANT OPTION FROM '{{name}}'@'%';
REVOKE ALL PRIVILEGES, GRANT OPTION FROM '{{name}}'@'%';
DROP USER '{{name}}'@'%'
`
@@ -174,8 +174,8 @@ func (m *MySQL) DeleteUser(ctx context.Context, req dbplugin.DeleteUserRequest)
// This is not a prepared statement because not all commands are supported
// 1295: This command is not supported in the prepared statement protocol yet
// Reference https://mariadb.com/kb/en/mariadb/prepare-statement/
query = strings.Replace(query, "{{name}}", req.Username, -1)
query = strings.Replace(query, "{{username}}", req.Username, -1)
query = strings.ReplaceAll(query, "{{name}}", req.Username)
query = strings.ReplaceAll(query, "{{username}}", req.Username)
_, err = tx.ExecContext(ctx, query)
if err != nil {
return dbplugin.DeleteUserResponse{}, err