aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/middleware/accept_requests_test.go9
-rw-r--r--internal/symbol/goapi.go7
-rw-r--r--internal/testing/htmlcheck/query.go11
3 files changed, 15 insertions, 12 deletions
diff --git a/internal/middleware/accept_requests_test.go b/internal/middleware/accept_requests_test.go
index 24f5fa19..e1971bac 100644
--- a/internal/middleware/accept_requests_test.go
+++ b/internal/middleware/accept_requests_test.go
@@ -7,6 +7,7 @@ package middleware
import (
"net/http"
"net/http/httptest"
+ "strings"
"testing"
)
@@ -62,20 +63,20 @@ func TestAcceptRequests_URILength(t *testing.T) {
defer ts.Close()
c := ts.Client()
- var longURL string
+ var longURL strings.Builder
// Create a URL with 990 characters.
numParts := maxURILength/2 - 5
for range numParts {
- longURL += "/a"
+ longURL.WriteString("/a")
}
// Without this query param, the length of longURL will be < maxURILength.
- longURL += "?q=randomstring"
+ longURL.WriteString("?q=randomstring")
for _, test := range []struct {
name, urlPath string
want bool
}{
{"short URL", "/shorturlpath", true},
- {"long URL", longURL, false},
+ {"long URL", longURL.String(), false},
} {
called = false
req, err := http.NewRequest(http.MethodGet, ts.URL+test.urlPath, nil)
diff --git a/internal/symbol/goapi.go b/internal/symbol/goapi.go
index fd4cc840..5dbea638 100644
--- a/internal/symbol/goapi.go
+++ b/internal/symbol/goapi.go
@@ -83,7 +83,8 @@ func tagKey(dir string, context *build.Context, tags []string) string {
ctags[tag] = true
}
// TODO: ReleaseTags (need to load default)
- key := dir
+ var key strings.Builder
+ key.WriteString(dir)
// explicit on GOOS and GOARCH as global cache will use "all" cached packages for
// an indirect imported package. See https://github.com/golang/go/issues/21181
// for more detail.
@@ -91,11 +92,11 @@ func tagKey(dir string, context *build.Context, tags []string) string {
sort.Strings(tags)
for _, tag := range tags {
if ctags[tag] {
- key += "," + tag
+ key.WriteString("," + tag)
ctags[tag] = false
}
}
- return key
+ return key.String()
}
var listCache sync.Map // map[string]listImports, keyed by contextName
diff --git a/internal/testing/htmlcheck/query.go b/internal/testing/htmlcheck/query.go
index fe594150..ea082270 100644
--- a/internal/testing/htmlcheck/query.go
+++ b/internal/testing/htmlcheck/query.go
@@ -29,15 +29,16 @@ func (s *selector) String() string {
if s == nil {
return "nil"
}
- str := "["
+ var str strings.Builder
+ str.WriteString("[")
for i, atom := range s.atoms {
- str += fmt.Sprintf("%#v", atom)
+ str.WriteString(fmt.Sprintf("%#v", atom))
if i != len(s.atoms)-1 {
- str += ","
+ str.WriteString(",")
}
}
- str += "]->" + s.next.String()
- return str
+ str.WriteString("]->" + s.next.String())
+ return str.String()
}
// selectorAtom represents a part of a selector that individually