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:
@@ -323,11 +323,11 @@ func (mw *DatabaseErrorSanitizerMiddleware) sanitize(err error) error {
|
||||
// error without changing the actual error message
|
||||
s, ok := status.FromError(err)
|
||||
if ok {
|
||||
err = status.Error(s.Code(), strings.Replace(s.Message(), k, v.(string), -1))
|
||||
err = status.Error(s.Code(), strings.ReplaceAll(s.Message(), k, v.(string)))
|
||||
continue
|
||||
}
|
||||
|
||||
err = errors.New(strings.Replace(err.Error(), k, v.(string), -1))
|
||||
err = errors.New(strings.ReplaceAll(err.Error(), k, v.(string)))
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user