Skip to content

Commit 7a27829

Browse files
authored
Run modernize and gofumpt to update and improve syntax (#841)
This is the result of running: ``` $ go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./... $ gofumpt -w . ````
1 parent 3ffef0a commit 7a27829

7 files changed

+36
-36
lines changed

client_ext_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ type notModifiedPingServer struct {
715715

716716
func (s *notModifiedPingServer) Ping(
717717
_ context.Context,
718-
req *connect.Request[pingv1.PingRequest]) (*connect.Response[pingv1.PingResponse], error) {
718+
req *connect.Request[pingv1.PingRequest],
719+
) (*connect.Response[pingv1.PingResponse], error) {
719720
if req.HTTPMethod() == http.MethodGet && req.Header().Get("If-None-Match") == s.etag {
720721
return nil, connect.NewNotModifiedError(http.Header{"Etag": []string{s.etag}})
721722
}

codec_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import (
2727
"google.golang.org/protobuf/types/known/structpb"
2828
)
2929

30-
func convertMapToInterface(stringMap map[string]string) map[string]interface{} {
31-
interfaceMap := make(map[string]interface{})
30+
func convertMapToInterface(stringMap map[string]string) map[string]any {
31+
interfaceMap := make(map[string]any)
3232
for key, value := range stringMap {
3333
interfaceMap[key] = value
3434
}

connect_ext_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"errors"
2525
"fmt"
2626
"io"
27+
"maps"
2728
"math"
2829
rand "math/rand/v2"
2930
"net"
@@ -2100,9 +2101,7 @@ func TestConnectProtocolHeaderRequired(t *testing.T) {
21002101
)
21012102
assert.Nil(t, err)
21022103
req.Header.Set("Content-Type", "application/json")
2103-
for k, v := range tcase.headers {
2104-
req.Header[k] = v
2105-
}
2104+
maps.Copy(req.Header, tcase.headers)
21062105
response, err := server.Client().Do(req)
21072106
assert.Nil(t, err)
21082107
assert.Nil(t, response.Body.Close())

duplex_http_call.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,15 @@ var _ messagePayload = nopPayload{}
363363
func (nopPayload) Read([]byte) (int, error) {
364364
return 0, io.EOF
365365
}
366+
366367
func (nopPayload) WriteTo(io.Writer) (int64, error) {
367368
return 0, nil
368369
}
370+
369371
func (nopPayload) Seek(int64, int) (int64, error) {
370372
return 0, nil
371373
}
374+
372375
func (nopPayload) Len() int {
373376
return 0
374377
}

header.go

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,31 @@ import (
1919
"net/http"
2020
)
2121

22-
var (
23-
//nolint:gochecknoglobals
24-
protocolHeaders = map[string]struct{}{
25-
// HTTP headers.
26-
headerContentType: {},
27-
headerContentLength: {},
28-
headerContentEncoding: {},
29-
headerHost: {},
30-
headerUserAgent: {},
31-
headerTrailer: {},
32-
headerDate: {},
33-
// Connect headers.
34-
connectUnaryHeaderAcceptCompression: {},
35-
connectUnaryTrailerPrefix: {},
36-
connectStreamingHeaderCompression: {},
37-
connectStreamingHeaderAcceptCompression: {},
38-
connectHeaderTimeout: {},
39-
connectHeaderProtocolVersion: {},
40-
// gRPC headers.
41-
grpcHeaderCompression: {},
42-
grpcHeaderAcceptCompression: {},
43-
grpcHeaderTimeout: {},
44-
grpcHeaderStatus: {},
45-
grpcHeaderMessage: {},
46-
grpcHeaderDetails: {},
47-
}
48-
)
22+
//nolint:gochecknoglobals
23+
var protocolHeaders = map[string]struct{}{
24+
// HTTP headers.
25+
headerContentType: {},
26+
headerContentLength: {},
27+
headerContentEncoding: {},
28+
headerHost: {},
29+
headerUserAgent: {},
30+
headerTrailer: {},
31+
headerDate: {},
32+
// Connect headers.
33+
connectUnaryHeaderAcceptCompression: {},
34+
connectUnaryTrailerPrefix: {},
35+
connectStreamingHeaderCompression: {},
36+
connectStreamingHeaderAcceptCompression: {},
37+
connectHeaderTimeout: {},
38+
connectHeaderProtocolVersion: {},
39+
// gRPC headers.
40+
grpcHeaderCompression: {},
41+
grpcHeaderAcceptCompression: {},
42+
grpcHeaderTimeout: {},
43+
grpcHeaderStatus: {},
44+
grpcHeaderMessage: {},
45+
grpcHeaderDetails: {},
46+
}
4947

5048
// EncodeBinaryHeader base64-encodes the data. It always emits unpadded values.
5149
//

internal/memhttp/listener.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ import (
2121
"sync"
2222
)
2323

24-
var (
25-
errListenerClosed = errors.New("listener closed")
26-
)
24+
var errListenerClosed = errors.New("listener closed")
2725

2826
// memoryListener is a net.Listener that listens on an in memory network.
2927
type memoryListener struct {

protocol_grpc_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ func TestGRPCWebTrailerMarshalling(t *testing.T) {
196196
marshalled := responseWriter.Body.String()
197197
assert.Equal(t, marshalled, "grpc-message: Foo\r\ngrpc-status: 0\r\nuser-provided: bar\r\n")
198198
}
199+
199200
func BenchmarkGRPCPercentEncoding(b *testing.B) {
200201
input := "Hello, 世界"
201202
want := "Hello, %E4%B8%96%E7%95%8C"

0 commit comments

Comments
 (0)