RedactSecret replaces every occurrence of secret in text with its masked form.
(text, secret string)
| 16 | |
| 17 | // RedactSecret replaces every occurrence of secret in text with its masked form. |
| 18 | func RedactSecret(text, secret string) string { |
| 19 | if secret == "" { |
| 20 | return text |
| 21 | } |
| 22 | return strings.ReplaceAll(text, secret, MaskAPIKey(secret)) |
| 23 | } |
| 24 | |
| 25 | // TruncateString shortens a string to a maximum length. |
| 26 | func TruncateString(s string, maxLength int) string { |