Skip to content

Commit e958154

Browse files
joshfreeCopilot
authored andcommitted
Use strings.SplitSeq for Cache-Control and Vary parsing
golangci-lint's modernize analyzer flags ranging over strings.Split; strings.SplitSeq avoids allocating the intermediate slice. Refs #3025 Co-authored-by: Copilot <[email protected]> Copilot-Session: 4959e1f9-f8e6-4e97-a487-f395a0123c79
1 parent 7667cc7 commit e958154

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎pkg/http/transport/etag.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (t *ETagTransport) RoundTrip(req *http.Request) (*http.Response, error) {
202202
// directive.
203203
func hasNoStore(h http.Header) bool {
204204
for _, cc := range h.Values(headers.CacheControlHeader) {
205-
for _, directive := range strings.Split(cc, ",") {
205+
for directive := range strings.SplitSeq(cc, ",") {
206206
if strings.EqualFold(strings.TrimSpace(directive), "no-store") {
207207
return true
208208
}
@@ -218,7 +218,7 @@ func storable(resp *http.Response) bool {
218218
return false
219219
}
220220
for _, vary := range resp.Header.Values(headers.VaryHeader) {
221-
for _, field := range strings.Split(vary, ",") {
221+
for field := range strings.SplitSeq(vary, ",") {
222222
if strings.TrimSpace(field) == "*" {
223223
return false
224224
}

0 commit comments

Comments
 (0)