【optimization】Use URL.Redacted method repleace redacted (#18716)

use URL.Redacted method replease redacted

Signed-off-by: lengrongfu <1275177125@qq.com>
This commit is contained in:
rongfu.leng 2023-05-29 16:37:51 +08:00 committed by GitHub
parent 1b1af4a14c
commit 4652d752b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 15 deletions

View File

@ -103,7 +103,7 @@ func Initialize(typ, addr string) error {
redactedAddr := addr
if u, err := url.Parse(addr); err == nil {
redactedAddr = redacted(u)
redactedAddr = u.Redacted()
}
options := []retry.Option{

14
src/lib/cache/util.go vendored
View File

@ -15,23 +15,9 @@
package cache
import (
"net/url"
"sync"
)
// TODO: use the URL.Redacted when golang upgrade to 1.15
func redacted(u *url.URL) string {
if u == nil {
return ""
}
ru := *u
if _, has := ru.User.Password(); has {
ru.User = url.UserPassword(ru.User.Username(), "xxxxx")
}
return ru.String()
}
type keyMutex struct {
m *sync.Map
}