Skip to content

Commit fe277ea

Browse files
committed
Fix all gofmt -s issues
1 parent 7582224 commit fe277ea

10 files changed

Lines changed: 41 additions & 44 deletions

File tree

lib/go/test/fuzz/fuzz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ import (
2727
"fmt"
2828
"strconv"
2929

30+
"github.com/apache/thrift/lib/go/test/fuzz/gen-go/fuzztest"
3031
"github.com/apache/thrift/lib/go/test/fuzz/gen-go/shared"
3132
"github.com/apache/thrift/lib/go/test/fuzz/gen-go/tutorial"
32-
"github.com/apache/thrift/lib/go/test/fuzz/gen-go/fuzztest"
3333
"github.com/apache/thrift/lib/go/thrift"
3434
)
3535

lib/go/test/fuzz/fuzz_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//go:build gofuzz
12
// +build gofuzz
23

34
/*

lib/go/test/tests/optional_fields_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func TestListNotEmpty(t *testing.T) {
182182
}
183183
}
184184

185-
//Make sure that optional fields are not being serialized
185+
// Make sure that optional fields are not being serialized
186186
func TestNoOptionalUnsetFieldsOnWire(t *testing.T) {
187187
mockCtrl := gomock.NewController(t)
188188
defer mockCtrl.Finish()
@@ -210,7 +210,7 @@ func TestNoSetToDefaultFieldsOnWire(t *testing.T) {
210210
ao.Write(context.Background(), proto)
211211
}
212212

213-
//Make sure that only one field is being serialized when set to non-default
213+
// Make sure that only one field is being serialized when set to non-default
214214
func TestOneISetFieldOnWire(t *testing.T) {
215215
mockCtrl := gomock.NewController(t)
216216
defer mockCtrl.Finish()

lib/go/thrift/compact_protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ const maxVarint64Bytes = 10
775775
func (p *TCompactProtocol) readVarint64() (int64, error) {
776776
shift := uint(0)
777777
result := int64(0)
778-
for rsize := 0; rsize < maxVarint64Bytes; rsize++ {
778+
for range maxVarint64Bytes {
779779
b, err := p.readByteDirect()
780780
if err != nil {
781781
return 0, err

lib/go/thrift/framed_transport.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ func NewTFramedTransportFactory(factory TTransportFactory) TTransportFactory {
6161

6262
// Deprecated: Use NewTFramedTransportFactoryConf instead.
6363
func NewTFramedTransportFactoryMaxLength(factory TTransportFactory, maxLength uint32) TTransportFactory {
64-
safeMax := maxLength
65-
if safeMax > math.MaxInt32 {
66-
safeMax = math.MaxInt32
67-
}
64+
safeMax := min(maxLength, math.MaxInt32)
6865

6966
return NewTFramedTransportFactoryConf(factory, &TConfiguration{
7067
MaxFrameSize: int32(safeMax),

lib/go/thrift/middleware.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ type ProcessorMiddleware func(name string, next TProcessorFunction) TProcessorFu
3535
//
3636
// Middlewares will be called in the order that they are defined:
3737
//
38-
// 1. Middlewares[0]
39-
// 2. Middlewares[1]
40-
// ...
41-
// N. Middlewares[n]
38+
// 1. Middlewares[0]
39+
// 2. Middlewares[1]
40+
// ...
41+
// N. Middlewares[n]
4242
func WrapProcessor(processor TProcessor, middlewares ...ProcessorMiddleware) TProcessor {
4343
for name, processorFunc := range processor.ProcessorMap() {
4444
wrapped := processorFunc
@@ -98,10 +98,10 @@ var (
9898
//
9999
// Middlewares will be called in the order that they are defined:
100100
//
101-
// 1. Middlewares[0]
102-
// 2. Middlewares[1]
103-
// ...
104-
// N. Middlewares[n]
101+
// 1. Middlewares[0]
102+
// 2. Middlewares[1]
103+
// ...
104+
// N. Middlewares[n]
105105
func WrapClient(client TClient, middlewares ...ClientMiddleware) TClient {
106106
// Add middlewares in reverse so the first in the list is the outermost.
107107
for i := len(middlewares) - 1; i >= 0; i-- {
@@ -117,12 +117,12 @@ func WrapClient(client TClient, middlewares ...ClientMiddleware) TClient {
117117
// By default if a client call gets an exception defined in the thrift IDL, for
118118
// example:
119119
//
120-
// service MyService {
121-
// FooResponse foo(1: FooRequest request) throws (
122-
// 1: Exception1 error1,
123-
// 2: Exception2 error2,
124-
// )
125-
// }
120+
// service MyService {
121+
// FooResponse foo(1: FooRequest request) throws (
122+
// 1: Exception1 error1,
123+
// 2: Exception2 error2,
124+
// )
125+
// }
126126
//
127127
// Exception1 or Exception2 will not be in the err return of TClient.Call,
128128
// but in the result TStruct instead, and there's no easy access to them.

lib/go/thrift/server_socket.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
* under the License.
1818
*/
1919

20-
2120
package thrift
2221

2322
import (
@@ -28,9 +27,9 @@ import (
2827

2928
type TServerSocket struct {
3029
// TServerSocketListenerFactory abstracts how listeners are created.
31-
listenerFactory func(net.Addr) (net.Listener, error)
32-
addr net.Addr
33-
clientTimeout time.Duration
30+
listenerFactory func(net.Addr) (net.Listener, error)
31+
addr net.Addr
32+
clientTimeout time.Duration
3433

3534
// Protects the listener and interrupted fields to make them thread safe.
3635
mu sync.RWMutex
@@ -66,9 +65,9 @@ func NewTServerSocketFromAddrTimeout(addr net.Addr, clientTimeout time.Duration)
6665
// Allows full customization (TLS, mocks, unix sockets, windows named pipes, etc.)
6766
func NewTServerSocketFromFactoryTimeout(listenerFactory func(addr net.Addr) (listener net.Listener, err error), addr net.Addr, clientTimeout time.Duration) *TServerSocket {
6867
return &TServerSocket{
69-
listenerFactory: listenerFactory,
70-
addr: addr,
71-
clientTimeout: clientTimeout,
68+
listenerFactory: listenerFactory,
69+
addr: addr,
70+
clientTimeout: clientTimeout,
7271
}
7372
}
7473

@@ -77,7 +76,7 @@ func (p *TServerSocket) try_listen(raise bool) error {
7776
defer p.mu.Unlock()
7877

7978
if p.listener != nil {
80-
if (raise) {
79+
if raise {
8180
return NewTTransportException(ALREADY_OPEN, "Server socket already open")
8281
}
8382
return nil
@@ -145,7 +144,7 @@ func (p *TServerSocket) Addr() net.Addr {
145144
func (p *TServerSocket) try_close(interrupt bool) error {
146145
p.mu.Lock()
147146
defer p.mu.Unlock()
148-
if (interrupt){
147+
if interrupt {
149148
p.interrupted = true
150149
}
151150

lib/go/thrift/socket.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ func NewTSocket(hostPort string) (*TSocket, error) {
5555
//
5656
// Example:
5757
//
58-
// trans := thrift.NewTSocketConf("localhost:9090", &TConfiguration{
59-
// ConnectTimeout: time.Second, // Use 0 for no timeout
60-
// SocketTimeout: time.Second, // Use 0 for no timeout
61-
// })
58+
// trans := thrift.NewTSocketConf("localhost:9090", &TConfiguration{
59+
// ConnectTimeout: time.Second, // Use 0 for no timeout
60+
// SocketTimeout: time.Second, // Use 0 for no timeout
61+
// })
6262
func NewTSocketConf(hostPort string, conf *TConfiguration) *TSocket {
6363
return NewTSocketFromAddrConf(tcpAddr(hostPort), conf)
6464
}
@@ -197,7 +197,7 @@ func (p *TSocket) Close() error {
197197
return p.conn.Close()
198198
}
199199

200-
//Returns the remote address of the socket.
200+
// Returns the remote address of the socket.
201201
func (p *TSocket) Addr() net.Addr {
202202
return p.addr
203203
}

lib/go/thrift/socket_unix_conn_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// +build !windows
1+
//go:build !windows
22

33
/*
44
* Licensed to the Apache Software Foundation (ASF) under one

lib/go/thrift/ssl_socket.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ type TSSLSocket struct {
4242
//
4343
// Example:
4444
//
45-
// trans := thrift.NewTSSLSocketConf("localhost:9090", &TConfiguration{
46-
// ConnectTimeout: time.Second, // Use 0 for no timeout
47-
// SocketTimeout: time.Second, // Use 0 for no timeout
45+
// trans := thrift.NewTSSLSocketConf("localhost:9090", &TConfiguration{
46+
// ConnectTimeout: time.Second, // Use 0 for no timeout
47+
// SocketTimeout: time.Second, // Use 0 for no timeout
4848
//
49-
// TLSConfig: &tls.Config{
50-
// // Fill in tls config here.
51-
// }
52-
// })
49+
// TLSConfig: &tls.Config{
50+
// // Fill in tls config here.
51+
// }
52+
// })
5353
func NewTSSLSocketConf(hostPort string, conf *TConfiguration) *TSSLSocket {
5454
if cfg := conf.GetTLSConfig(); cfg != nil && cfg.MinVersion == 0 {
5555
cfg.MinVersion = tls.VersionTLS10

0 commit comments

Comments
 (0)