Skip to content

Commit ff7560f

Browse files
authored
chore: modernize (#221)
The results of running go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./... See [modernize analyzer docs][1] for more info. [1]: https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
1 parent d2a914c commit ff7560f

File tree

10 files changed

+15
-83
lines changed

10 files changed

+15
-83
lines changed

httpbin/cmd/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func loadConfig(args []string, getEnvVal func(string) string, getEnviron func()
204204
}
205205

206206
// helper to generate a new ConfigError to return
207-
configErr := func(format string, a ...interface{}) error {
207+
configErr := func(format string, a ...any) error {
208208
return ConfigError{
209209
Err: fmt.Errorf(format, a...),
210210
Usage: usage,

httpbin/cmd/cmd_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ func TestLoadConfig(t *testing.T) {
528528
}
529529

530530
for name, tc := range testCases {
531-
tc := tc
532531
t.Run(name, func(t *testing.T) {
533532
t.Parallel()
534533

@@ -617,7 +616,6 @@ func TestMainImpl(t *testing.T) {
617616
}
618617

619618
for name, tc := range testCases {
620-
tc := tc
621619
t.Run(name, func(t *testing.T) {
622620
t.Parallel()
623621

httpbin/digest/digest_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ func TestHash(t *testing.T) {
118118
{digestAlgorithm(10), []byte("hello, world!\n"), "910c8bc73110b0cd1bc5d2bcae782511"},
119119
}
120120
for _, test := range tests {
121-
test := test
122121
t.Run(fmt.Sprintf("hash/%v", test.algorithm), func(t *testing.T) {
123122
t.Parallel()
124123
result := hash(test.data, test.algorithm)
@@ -180,7 +179,6 @@ func TestParseDictHeader(t *testing.T) {
180179
}
181180

182181
for _, test := range tests {
183-
test := test
184182
t.Run(test.input, func(t *testing.T) {
185183
t.Parallel()
186184
results := parseDictHeader(test.input)
@@ -272,7 +270,6 @@ func TestParseAuthorizationHeader(t *testing.T) {
272270
}
273271

274272
for i, test := range tests {
275-
test := test
276273
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
277274
t.Parallel()
278275
got := parseAuthorizationHeader(test.input)

httpbin/handlers.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func createSpecialCases(prefix string) map[int]*statusCase {
188188
]
189189
}
190190
`)
191-
statusHTTP300body := []byte(fmt.Sprintf(`<!doctype html>
191+
statusHTTP300body := fmt.Appendf(nil, `<!doctype html>
192192
<head>
193193
<title>Multiple Choices</title>
194194
</head>
@@ -198,15 +198,15 @@ func createSpecialCases(prefix string) map[int]*statusCase {
198198
<li><a href="%[1]s/image/png">/image/png</a></li>
199199
<li><a href="%[1]s/image/svg">/image/svg</a></li>
200200
</body>
201-
</html>`, prefix))
201+
</html>`, prefix)
202202

203-
statusHTTP308Body := []byte(fmt.Sprintf(`<!doctype html>
203+
statusHTTP308Body := fmt.Appendf(nil, `<!doctype html>
204204
<head>
205205
<title>Permanent Redirect</title>
206206
</head>
207207
<body>Permanently redirected to <a href="%[1]s/image/jpeg">%[1]s/image/jpeg</a>
208208
</body>
209-
</html>`, prefix))
209+
</html>`, prefix)
210210

211211
return map[int]*statusCase{
212212
300: {
@@ -1004,7 +1004,7 @@ func (h *HTTPBin) doLinksPage(w http.ResponseWriter, _ *http.Request, n int, off
10041004
w.WriteHeader(http.StatusOK)
10051005

10061006
w.Write([]byte("<html><head><title>Links</title></head><body>"))
1007-
for i := 0; i < n; i++ {
1007+
for i := range n {
10081008
if i == offset {
10091009
fmt.Fprintf(w, "%d ", i)
10101010
} else {

0 commit comments

Comments
 (0)