mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-02 19:47:54 +00:00 
			
		
		
		
	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:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user