Skip to content

Commit faebfcb

Browse files
thinkeroudfawley
authored andcommitted
Remove single-entry var blocks (grpc#1589)
1 parent 16c4192 commit faebfcb

File tree

13 files changed

+49
-80
lines changed

13 files changed

+49
-80
lines changed

backoff.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ import (
2525

2626
// DefaultBackoffConfig uses values specified for backoff in
2727
// https://github.com/grpc/grpc/blob/master/doc/connection-backoff.md.
28-
var (
29-
DefaultBackoffConfig = BackoffConfig{
30-
MaxDelay: 120 * time.Second,
31-
baseDelay: 1.0 * time.Second,
32-
factor: 1.6,
33-
jitter: 0.2,
34-
}
35-
)
28+
var DefaultBackoffConfig = BackoffConfig{
29+
MaxDelay: 120 * time.Second,
30+
baseDelay: 1.0 * time.Second,
31+
factor: 1.6,
32+
jitter: 0.2,
33+
}
3634

3735
// backoffStrategy defines the methodology for backing off after a grpc
3836
// connection failure.

benchmark/server/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ import (
3030
"google.golang.org/grpc/grpclog"
3131
)
3232

33-
var (
34-
duration = flag.Int("duration", math.MaxInt32, "The duration in seconds to run the benchmark server")
35-
)
33+
var duration = flag.Int("duration", math.MaxInt32, "The duration in seconds to run the benchmark server")
3634

3735
func main() {
3836
flag.Parse()

benchmark/worker/benchmark_client.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ import (
3737
"google.golang.org/grpc/testdata"
3838
)
3939

40-
var (
41-
caFile = flag.String("ca_file", "", "The file containing the CA root cert file")
42-
)
40+
var caFile = flag.String("ca_file", "", "The file containing the CA root cert file")
4341

4442
type lockingHistogram struct {
4543
mu sync.Mutex

codec.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,11 @@ func (protoCodec) String() string {
9292
return "proto"
9393
}
9494

95-
var (
96-
protoBufferPool = &sync.Pool{
97-
New: func() interface{} {
98-
return &cachedProtoBuffer{
99-
Buffer: proto.Buffer{},
100-
lastMarshaledSize: 16,
101-
}
102-
},
103-
}
104-
)
95+
var protoBufferPool = &sync.Pool{
96+
New: func() interface{} {
97+
return &cachedProtoBuffer{
98+
Buffer: proto.Buffer{},
99+
lastMarshaledSize: 16,
100+
}
101+
},
102+
}

credentials/credentials.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ import (
3434
"golang.org/x/net/context"
3535
)
3636

37-
var (
38-
// alpnProtoStr are the specified application level protocols for gRPC.
39-
alpnProtoStr = []string{"h2"}
40-
)
37+
// alpnProtoStr are the specified application level protocols for gRPC.
38+
var alpnProtoStr = []string{"h2"}
4139

4240
// PerRPCCredentials defines the common interface for the credentials which need to
4341
// attach security information to every RPC (e.g., oauth2).
@@ -74,11 +72,9 @@ type AuthInfo interface {
7472
AuthType() string
7573
}
7674

77-
var (
78-
// ErrConnDispatched indicates that rawConn has been dispatched out of gRPC
79-
// and the caller should not close rawConn.
80-
ErrConnDispatched = errors.New("credentials: rawConn is dispatched out of gRPC")
81-
)
75+
// ErrConnDispatched indicates that rawConn has been dispatched out of gRPC
76+
// and the caller should not close rawConn.
77+
var ErrConnDispatched = errors.New("credentials: rawConn is dispatched out of gRPC")
8278

8379
// TransportCredentials defines the common interface for all the live gRPC wire
8480
// protocols and supported transport security protocols (e.g., TLS, SSL).

examples/route_guide/mock_routeguide/rg_mock_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@ import (
2929
rgpb "google.golang.org/grpc/examples/route_guide/routeguide"
3030
)
3131

32-
var (
33-
msg = &rgpb.RouteNote{
34-
Location: &rgpb.Point{Latitude: 17, Longitude: 29},
35-
Message: "Taxi-cab",
36-
}
37-
)
32+
var msg = &rgpb.RouteNote{
33+
Location: &rgpb.Point{Latitude: 17, Longitude: 29},
34+
Message: "Taxi-cab",
35+
}
3836

3937
func TestRouteChat(t *testing.T) {
4038
ctrl := gomock.NewController(t)

interop/test_utils.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,10 @@ func DoPerRPCCreds(tc testpb.TestServiceClient, serviceAccountKeyFile, oauthScop
394394
}
395395
}
396396

397-
var (
398-
testMetadata = metadata.MD{
399-
"key1": []string{"value1"},
400-
"key2": []string{"value2"},
401-
}
402-
)
397+
var testMetadata = metadata.MD{
398+
"key1": []string{"value1"},
399+
"key2": []string{"value2"},
400+
}
403401

404402
// DoCancelAfterBegin cancels the RPC after metadata has been sent but before payloads are sent.
405403
func DoCancelAfterBegin(tc testpb.TestServiceClient, args ...grpc.CallOption) {

resolver/dns/dns_resolver.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ const (
5050
txtAttribute = "grpc_config="
5151
)
5252

53-
var (
54-
errMissingAddr = errors.New("missing address")
55-
)
53+
var errMissingAddr = errors.New("missing address")
5654

5755
// NewBuilder creates a dnsBuilder which is used to factory DNS resolvers.
5856
func NewBuilder() resolver.Builder {

resolver/dns/dns_resolver_test.go

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,8 @@ func div(b []byte) []string {
150150
// resolver functionality, with scfs as the input and scs used for validation of
151151
// the output. For scfs[3], it corresponds to empty service config, since there
152152
// isn't a matched choice.
153-
var (
154-
scfs = []string{
155-
`[
153+
var scfs = []string{
154+
`[
156155
{
157156
"clientLanguage": [
158157
"CPP",
@@ -242,7 +241,7 @@ var (
242241
}
243242
}
244243
]`,
245-
`[
244+
`[
246245
{
247246
"clientLanguage": [
248247
"CPP",
@@ -335,7 +334,7 @@ var (
335334
}
336335
}
337336
]`,
338-
`[
337+
`[
339338
{
340339
"clientLanguage": [
341340
"CPP",
@@ -434,7 +433,7 @@ var (
434433
}
435434
}
436435
]`,
437-
`[
436+
`[
438437
{
439438
"clientLanguage": [
440439
"CPP",
@@ -489,13 +488,11 @@ var (
489488
}
490489
}
491490
]`,
492-
}
493-
)
491+
}
494492

495493
// scs contains an array of service config string in JSON format.
496-
var (
497-
scs = []string{
498-
`{
494+
var scs = []string{
495+
`{
499496
"methodConfig": [
500497
{
501498
"name": [
@@ -508,7 +505,7 @@ var (
508505
}
509506
]
510507
}`,
511-
`{
508+
`{
512509
"methodConfig": [
513510
{
514511
"name": [
@@ -524,7 +521,7 @@ var (
524521
}
525522
]
526523
}`,
527-
`{
524+
`{
528525
"loadBalancingPolicy": "round_robin",
529526
"methodConfig": [
530527
{
@@ -546,8 +543,7 @@ var (
546543
}
547544
]
548545
}`,
549-
}
550-
)
546+
}
551547

552548
// scLookupTbl is a set, which contains targets that have service config. Target
553549
// not in this set should not have service config.

resolver/dns/go17_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ import (
2727
"golang.org/x/net/context"
2828
)
2929

30-
var (
31-
errForInvalidTarget = fmt.Errorf("invalid target address [2001:db8:a0b:12f0::1, error info: missing ']' in address [2001:db8:a0b:12f0::1:443")
32-
)
30+
var errForInvalidTarget = fmt.Errorf("invalid target address [2001:db8:a0b:12f0::1, error info: missing ']' in address [2001:db8:a0b:12f0::1:443")
3331

3432
func replaceNetFunc() func() {
3533
oldLookupHost := lookupHost

0 commit comments

Comments
 (0)