aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/auth/auth.go5
-rw-r--r--internal/fetch/load.go5
-rw-r--r--internal/log/stackdriverlogger/log.go9
-rw-r--r--internal/proxy/proxytest/module.go5
-rw-r--r--internal/symbol/generate.go5
5 files changed, 11 insertions, 18 deletions
diff --git a/internal/auth/auth.go b/internal/auth/auth.go
index caa97abb..2eb1bac6 100644
--- a/internal/auth/auth.go
+++ b/internal/auth/auth.go
@@ -8,6 +8,7 @@ package auth
import (
"context"
"fmt"
+ "maps"
"net/http"
"golang.org/x/pkgsite/internal/derrors"
@@ -89,9 +90,7 @@ func (t *HeadersTransport) RoundTrip(req *http.Request) (*http.Response, error)
// Copy req and its headers.
newReq := *req
newReq.Header = make(http.Header)
- for k, v := range req.Header {
- newReq.Header[k] = v
- }
+ maps.Copy(newReq.Header, req.Header)
// Add or overwrite our headers.
for h, v := range t.Headers {
newReq.Header.Set(h, v)
diff --git a/internal/fetch/load.go b/internal/fetch/load.go
index 82667f9e..bde5469d 100644
--- a/internal/fetch/load.go
+++ b/internal/fetch/load.go
@@ -16,6 +16,7 @@ import (
"go/token"
"io"
"io/fs"
+ "maps"
"net/http"
"os"
"path"
@@ -447,9 +448,7 @@ func matchingFiles(goos, goarch string, importPath string, allFiles map[string][
// Copy the input map so we don't modify it.
matchedFiles = map[string][]byte{}
- for n, c := range allFiles {
- matchedFiles[n] = c
- }
+ maps.Copy(matchedFiles, allFiles)
for name := range allFiles {
match, err := bctx.MatchFile(".", name) // This will access the file we just added to files map above.
if err != nil {
diff --git a/internal/log/stackdriverlogger/log.go b/internal/log/stackdriverlogger/log.go
index 0238070f..5de8653d 100644
--- a/internal/log/stackdriverlogger/log.go
+++ b/internal/log/stackdriverlogger/log.go
@@ -11,6 +11,7 @@ import (
"errors"
"fmt"
stdlog "log"
+ "maps"
"os"
"strings"
"sync"
@@ -41,9 +42,7 @@ func NewContextWithLabel(ctx context.Context, key, value string) context.Context
oldLabels, _ := ctx.Value(labelsKey{}).(map[string]string)
// Copy the labels, to preserve immutability of contexts.
newLabels := map[string]string{}
- for k, v := range oldLabels {
- newLabels[k] = v
- }
+ maps.Copy(newLabels, oldLabels)
newLabels[key] = value
return context.WithValue(ctx, labelsKey{}, newLabels)
}
@@ -86,9 +85,7 @@ func (l *logger) Log(ctx context.Context, s log.Severity, payload any) {
es := experimentString(ctx)
if len(es) > 0 {
nl := map[string]string{}
- for k, v := range labels {
- nl[k] = v
- }
+ maps.Copy(nl, labels)
nl["experiments"] = es
labels = nl
}
diff --git a/internal/proxy/proxytest/module.go b/internal/proxy/proxytest/module.go
index 7352e613..f38bca58 100644
--- a/internal/proxy/proxytest/module.go
+++ b/internal/proxy/proxytest/module.go
@@ -7,6 +7,7 @@ package proxytest
import (
"fmt"
+ "maps"
"strings"
)
@@ -69,9 +70,7 @@ func (m *Module) setFile(filename string, contents *string, mustExist bool) *Mod
m2 := *m
if m.Files != nil {
m2.Files = map[string]string{}
- for k, v := range m.Files {
- m2.Files[k] = v
- }
+ maps.Copy(m2.Files, m.Files)
}
if contents == nil {
delete(m2.Files, filename)
diff --git a/internal/symbol/generate.go b/internal/symbol/generate.go
index 71e0e5ff..cd150a5d 100644
--- a/internal/symbol/generate.go
+++ b/internal/symbol/generate.go
@@ -14,6 +14,7 @@ import (
"go/types"
"io"
"log"
+ "maps"
"os"
"os/exec"
"path/filepath"
@@ -264,9 +265,7 @@ func (w *Walker) loadImports(pkgPath string) {
if len(pkg.ImportMap) > 0 {
importMap[pkg.Dir] = make(map[string]string, len(pkg.ImportMap))
}
- for k, v := range pkg.ImportMap {
- importMap[pkg.Dir][k] = v
- }
+ maps.Copy(importMap[pkg.Dir], pkg.ImportMap)
}
sort.Strings(packages)
imports = listImports{