go: Fix things staticcheck complains about
Client: go
Staticcheck is the recommended replacement of the frozen and deprecated
official golint linter [1].
Fix the things it complained about (or add lint:ignore directive) in:
- lib/go/thrift
- lib/go/test/tests
- tutorial/go/src
- test/go/src
- compiler generated code
The majority of the fixes are in the following categories:
- Use of deprecated function (mainly the TConfiguration related ones)
- Redundant break in switch cases
- Unused and unexported variables/fields/functions
Also in the same spirit as fb539ae, remove the error return from
NewTSSLSocket as it can never be non-nil.
This change will be cherry-picked into 0.15.0 branch after merged.
[1]: https://groups.google.com/g/golang-nuts/c/rCP70Aq_tBc
diff --git a/test/go/src/common/server.go b/test/go/src/common/server.go
index 6e3a5d3..f48389d 100644
--- a/test/go/src/common/server.go
+++ b/test/go/src/common/server.go
@@ -31,7 +31,6 @@
var (
debugServerProtocol bool
- certPath string
)
func init() {
@@ -46,28 +45,30 @@
protocol string,
ssl bool,
certPath string,
- handler thrifttest.ThriftTest) (thrift.TProcessor, thrift.TServerTransport, thrift.TTransportFactory, thrift.TProtocolFactory, error) {
+ handler thrifttest.ThriftTest,
+) (thrift.TProcessor, thrift.TServerTransport, thrift.TTransportFactory, thrift.TProtocolFactory, error) {
var err error
hostPort := fmt.Sprintf("%s:%d", host, port)
+ var cfg *thrift.TConfiguration = nil
var protocolFactory thrift.TProtocolFactory
switch protocol {
case "compact":
- protocolFactory = thrift.NewTCompactProtocolFactory()
+ protocolFactory = thrift.NewTCompactProtocolFactoryConf(cfg)
case "simplejson":
- protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
+ protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(cfg)
case "json":
protocolFactory = thrift.NewTJSONProtocolFactory()
case "binary":
- protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
+ protocolFactory = thrift.NewTBinaryProtocolFactoryConf(nil)
case "header":
- protocolFactory = thrift.NewTHeaderProtocolFactory()
+ protocolFactory = thrift.NewTHeaderProtocolFactoryConf(nil)
default:
- return nil, nil, nil, nil, fmt.Errorf("Invalid protocol specified %s", protocol)
+ return nil, nil, nil, nil, fmt.Errorf("invalid protocol specified %s", protocol)
}
if debugServerProtocol {
- protocolFactory = thrift.NewTDebugProtocolFactory(protocolFactory, "server:")
+ protocolFactory = thrift.NewTDebugProtocolFactoryWithLogger(protocolFactory, "server:", thrift.StdLogger(nil))
}
var serverTransport thrift.TServerTransport
@@ -98,7 +99,7 @@
transportFactory = nil
case "framed":
transportFactory = thrift.NewTTransportFactory()
- transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
+ transportFactory = thrift.NewTFramedTransportFactoryConf(transportFactory, nil)
case "buffered":
transportFactory = thrift.NewTBufferedTransportFactory(8192)
case "zlib":
@@ -106,7 +107,7 @@
case "":
transportFactory = thrift.NewTTransportFactory()
default:
- return nil, nil, nil, nil, fmt.Errorf("Invalid transport specified %s", transport)
+ return nil, nil, nil, nil, fmt.Errorf("invalid transport specified %s", transport)
}
processor := thrifttest.NewThriftTestProcessor(handler)