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/tutorial/go/src/main.go b/tutorial/go/src/main.go
index afac6bb..2b6f230 100644
--- a/tutorial/go/src/main.go
+++ b/tutorial/go/src/main.go
@@ -20,6 +20,7 @@
*/
import (
+ "crypto/tls"
"flag"
"fmt"
"os"
@@ -47,13 +48,13 @@
var protocolFactory thrift.TProtocolFactory
switch *protocol {
case "compact":
- protocolFactory = thrift.NewTCompactProtocolFactory()
+ protocolFactory = thrift.NewTCompactProtocolFactoryConf(nil)
case "simplejson":
- protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
+ protocolFactory = thrift.NewTSimpleJSONProtocolFactoryConf(nil)
case "json":
protocolFactory = thrift.NewTJSONProtocolFactory()
case "binary", "":
- protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
+ protocolFactory = thrift.NewTBinaryProtocolFactoryConf(nil)
default:
fmt.Fprint(os.Stderr, "Invalid protocol specified", protocol, "\n")
Usage()
@@ -61,6 +62,11 @@
}
var transportFactory thrift.TTransportFactory
+ cfg := &thrift.TConfiguration{
+ TLSConfig: &tls.Config{
+ InsecureSkipVerify: true,
+ },
+ }
if *buffered {
transportFactory = thrift.NewTBufferedTransportFactory(8192)
} else {
@@ -68,7 +74,7 @@
}
if *framed {
- transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
+ transportFactory = thrift.NewTFramedTransportFactoryConf(transportFactory, cfg)
}
if *server {
@@ -76,7 +82,7 @@
fmt.Println("error running server:", err)
}
} else {
- if err := runClient(transportFactory, protocolFactory, *addr, *secure); err != nil {
+ if err := runClient(transportFactory, protocolFactory, *addr, *secure, cfg); err != nil {
fmt.Println("error running client:", err)
}
}