refactor: replace map iteration with maps.Copy/Clone

Signed-off-by: whosehang <whosehang@outlook.com>
This commit is contained in:
whosehang
2025-05-03 09:24:10 +08:00
parent 95647cba1d
commit fea3638384
5 changed files with 11 additions and 18 deletions

View File

@@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io"
"maps"
"net/http"
"net/url"
"sort"
@@ -137,9 +138,7 @@ func (app *testHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
app.responseMap[request.String()] = responses[1:]
responseHeader := w.Header()
for k, v := range response.Headers {
responseHeader[k] = v
}
maps.Copy(responseHeader, response.Headers)
w.WriteHeader(response.StatusCode)