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

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