diff --git a/metrics/label.go b/metrics/label.go index 56af8ced0c..0147627a2a 100644 --- a/metrics/label.go +++ b/metrics/label.go @@ -47,7 +47,5 @@ func (l *Label) Snapshot() *LabelSnapshot { func (l *Label) Mark(value map[string]interface{}) { l.mutex.Lock() defer l.mutex.Unlock() - for k, v := range value { - l.value[k] = v - } + maps.Copy(l.value, value) } diff --git a/rpc/client_opt.go b/rpc/client_opt.go index 3fa045a9b9..4079b51942 100644 --- a/rpc/client_opt.go +++ b/rpc/client_opt.go @@ -17,6 +17,7 @@ package rpc import ( + "maps" "net/http" "github.com/gorilla/websocket" @@ -89,9 +90,7 @@ func WithHeader(key, value string) ClientOption { func WithHeaders(headers http.Header) ClientOption { return optionFunc(func(cfg *clientConfig) { cfg.initHeaders() - for k, vs := range headers { - cfg.httpHeaders[k] = vs - } + maps.Copy(cfg.httpHeaders, headers) }) } diff --git a/rpc/http.go b/rpc/http.go index 59fcc9141a..f8602a61a5 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -23,6 +23,7 @@ import ( "errors" "fmt" "io" + "maps" "math" "mime" "net/http" @@ -147,9 +148,7 @@ func newClientTransportHTTP(endpoint string, cfg *clientConfig) reconnectFunc { headers := make(http.Header, 2+len(cfg.httpHeaders)) headers.Set("accept", contentType) headers.Set("content-type", contentType) - for key, values := range cfg.httpHeaders { - headers[key] = values - } + maps.Copy(headers, cfg.httpHeaders) client := cfg.httpClient if client == nil { diff --git a/rpc/websocket.go b/rpc/websocket.go index e211b4d7b9..ccf496317f 100644 --- a/rpc/websocket.go +++ b/rpc/websocket.go @@ -20,6 +20,7 @@ import ( "context" "encoding/base64" "fmt" + "maps" "net/http" "net/url" "os" @@ -240,9 +241,7 @@ func newClientTransportWS(endpoint string, cfg *clientConfig) (reconnectFunc, er if err != nil { return nil, err } - for key, values := range cfg.httpHeaders { - header[key] = values - } + maps.Copy(header, cfg.httpHeaders) connect := func(ctx context.Context) (ServerCodec, error) { header := header.Clone()