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/lib/go/test/tests/client_error_test.go b/lib/go/test/tests/client_error_test.go
index 64339dc..385f6f5 100644
--- a/lib/go/test/tests/client_error_test.go
+++ b/lib/go/test/tests/client_error_test.go
@@ -406,7 +406,9 @@
 	if failAt == 50 {
 		err = failWith
 	}
+	//lint:ignore SA4006 to keep it consistent with other checks above
 	last = protocol.EXPECT().ReadMessageEnd(context.Background()).Return(err).After(last)
+	//lint:ignore S1008 to keep it consistent with other checks above
 	if failAt == 50 {
 		return true
 	}
@@ -631,7 +633,9 @@
 	if failAt == 10 {
 		err = failWith
 	}
+	//lint:ignore SA4006 to keep it consistent with other checks above
 	last = protocol.EXPECT().ReadMessageEnd(context.Background()).Return(err).After(last)
+	//lint:ignore S1008 to keep it consistent with other checks above
 	if failAt == 10 {
 		return true
 	}
diff --git a/lib/go/test/tests/multiplexed_protocol_test.go b/lib/go/test/tests/multiplexed_protocol_test.go
index a5975b7..72f174e 100644
--- a/lib/go/test/tests/multiplexed_protocol_test.go
+++ b/lib/go/test/tests/multiplexed_protocol_test.go
@@ -51,8 +51,12 @@
 }
 
 func createTransport(addr net.Addr) (thrift.TTransport, error) {
-	socket := thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT, TIMEOUT)
-	transport := thrift.NewTFramedTransport(socket)
+	cfg := &thrift.TConfiguration{
+		ConnectTimeout: TIMEOUT,
+		SocketTimeout:  TIMEOUT,
+	}
+	socket := thrift.NewTSocketFromAddrConf(addr, cfg)
+	transport := thrift.NewTFramedTransportConf(socket, cfg)
 	err := transport.Open()
 	if err != nil {
 		return nil, err
@@ -62,9 +66,9 @@
 
 func TestMultiplexedProtocolFirst(t *testing.T) {
 	processor := thrift.NewTMultiplexedProcessor()
-	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
+	protocolFactory := thrift.NewTBinaryProtocolFactoryConf(nil)
 	transportFactory := thrift.NewTTransportFactory()
-	transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
+	transportFactory = thrift.NewTFramedTransportFactoryConf(transportFactory, nil)
 	addr := FindAvailableTCPServerPort()
 	serverTransport, err := thrift.NewTServerSocketTimeout(addr.String(), TIMEOUT)
 	if err != nil {
@@ -87,7 +91,7 @@
 		t.Fatal(err)
 	}
 	defer transport.Close()
-	protocol := thrift.NewTMultiplexedProtocol(thrift.NewTBinaryProtocolTransport(transport), "FirstService")
+	protocol := thrift.NewTMultiplexedProtocol(thrift.NewTBinaryProtocolConf(transport, nil), "FirstService")
 
 	client := multiplexedprotocoltest.NewFirstClient(thrift.NewTStandardClient(protocol, protocol))
 
@@ -101,9 +105,9 @@
 
 func TestMultiplexedProtocolSecond(t *testing.T) {
 	processor := thrift.NewTMultiplexedProcessor()
-	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
+	protocolFactory := thrift.NewTBinaryProtocolFactoryConf(nil)
 	transportFactory := thrift.NewTTransportFactory()
-	transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
+	transportFactory = thrift.NewTFramedTransportFactoryConf(transportFactory, nil)
 	addr := FindAvailableTCPServerPort()
 	serverTransport, err := thrift.NewTServerSocketTimeout(addr.String(), TIMEOUT)
 	if err != nil {
@@ -126,7 +130,7 @@
 		t.Fatal(err)
 	}
 	defer transport.Close()
-	protocol := thrift.NewTMultiplexedProtocol(thrift.NewTBinaryProtocolTransport(transport), "SecondService")
+	protocol := thrift.NewTMultiplexedProtocol(thrift.NewTBinaryProtocolConf(transport, nil), "SecondService")
 
 	client := multiplexedprotocoltest.NewSecondClient(thrift.NewTStandardClient(protocol, protocol))
 
@@ -140,9 +144,9 @@
 
 func TestMultiplexedProtocolLegacy(t *testing.T) {
 	processor := thrift.NewTMultiplexedProcessor()
-	protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
+	protocolFactory := thrift.NewTBinaryProtocolFactoryConf(nil)
 	transportFactory := thrift.NewTTransportFactory()
-	transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
+	transportFactory = thrift.NewTFramedTransportFactoryConf(transportFactory, nil)
 	addr := FindAvailableTCPServerPort()
 	serverTransport, err := thrift.NewTServerSocketTimeout(addr.String(), TIMEOUT)
 	if err != nil {
@@ -167,10 +171,10 @@
 	}
 	defer transport.Close()
 
-	protocol := thrift.NewTBinaryProtocolTransport(transport)
+	protocol := thrift.NewTBinaryProtocolConf(transport, nil)
 	client := multiplexedprotocoltest.NewSecondClient(thrift.NewTStandardClient(protocol, protocol))
 
-	ret, err := client.ReturnTwo(defaultCtx)
+	_, err = client.ReturnTwo(defaultCtx)
 	//expect error since default processor is not registered
 	if err == nil {
 		t.Fatal("Expecting error")
@@ -185,10 +189,10 @@
 	}
 	defer transport.Close()
 
-	protocol = thrift.NewTBinaryProtocolTransport(transport)
+	protocol = thrift.NewTBinaryProtocolConf(transport, nil)
 	client = multiplexedprotocoltest.NewSecondClient(thrift.NewTStandardClient(protocol, protocol))
 
-	ret, err = client.ReturnTwo(defaultCtx)
+	ret, err := client.ReturnTwo(defaultCtx)
 	if err != nil {
 		t.Fatal("Unable to call legacy server:", err)
 	}
diff --git a/lib/go/test/tests/one_way_test.go b/lib/go/test/tests/one_way_test.go
index 295dc1f..6661812 100644
--- a/lib/go/test/tests/one_way_test.go
+++ b/lib/go/test/tests/one_way_test.go
@@ -66,8 +66,12 @@
 }
 
 func TestInitOnewayClient(t *testing.T) {
-	transport := thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT, TIMEOUT)
-	protocol := thrift.NewTBinaryProtocolTransport(transport)
+	cfg := &thrift.TConfiguration{
+		ConnectTimeout: TIMEOUT,
+		SocketTimeout:  TIMEOUT,
+	}
+	transport := thrift.NewTSocketFromAddrConf(addr, cfg)
+	protocol := thrift.NewTBinaryProtocolConf(transport, cfg)
 	client = onewaytest.NewOneWayClient(thrift.NewTStandardClient(protocol, protocol))
 	err := transport.Open()
 	if err != nil {
diff --git a/lib/go/test/tests/protocols_test.go b/lib/go/test/tests/protocols_test.go
index 351fe59..d4b53f2 100644
--- a/lib/go/test/tests/protocols_test.go
+++ b/lib/go/test/tests/protocols_test.go
@@ -26,8 +26,11 @@
 	"github.com/apache/thrift/lib/go/thrift"
 )
 
-func RunSocketTestSuite(t *testing.T, protocolFactory thrift.TProtocolFactory,
-	transportFactory thrift.TTransportFactory) {
+func RunSocketTestSuite(
+	t *testing.T,
+	protocolFactory thrift.TProtocolFactory,
+	transportFactory thrift.TTransportFactory,
+) {
 	// server
 	var err error
 	addr = FindAvailableTCPServerPort()
@@ -42,7 +45,12 @@
 	go server.Serve()
 
 	// client
-	var transport thrift.TTransport = thrift.NewTSocketFromAddrTimeout(addr, TIMEOUT, TIMEOUT)
+	cfg := &thrift.TConfiguration{
+		ConnectTimeout: TIMEOUT,
+		SocketTimeout:  TIMEOUT,
+	}
+	thrift.PropagateTConfiguration(transportFactory, cfg)
+	var transport thrift.TTransport = thrift.NewTSocketFromAddrConf(addr, cfg)
 	transport, err = transportFactory.GetTransport(transport)
 	if err != nil {
 		t.Fatal(err)
@@ -60,39 +68,57 @@
 
 // Run test suite using TJSONProtocol
 func TestTJSONProtocol(t *testing.T) {
-	RunSocketTestSuite(t,
+	RunSocketTestSuite(
+		t,
 		thrift.NewTJSONProtocolFactory(),
-		thrift.NewTTransportFactory())
-	RunSocketTestSuite(t,
+		thrift.NewTTransportFactory(),
+	)
+	RunSocketTestSuite(
+		t,
 		thrift.NewTJSONProtocolFactory(),
-		thrift.NewTBufferedTransportFactory(8912))
-	RunSocketTestSuite(t,
+		thrift.NewTBufferedTransportFactory(8912),
+	)
+	RunSocketTestSuite(
+		t,
 		thrift.NewTJSONProtocolFactory(),
-		thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory()))
+		thrift.NewTFramedTransportFactoryConf(thrift.NewTTransportFactory(), nil),
+	)
 }
 
 // Run test suite using TBinaryProtocol
 func TestTBinaryProtocol(t *testing.T) {
-	RunSocketTestSuite(t,
-		thrift.NewTBinaryProtocolFactoryDefault(),
-		thrift.NewTTransportFactory())
-	RunSocketTestSuite(t,
-		thrift.NewTBinaryProtocolFactoryDefault(),
-		thrift.NewTBufferedTransportFactory(8912))
-	RunSocketTestSuite(t,
-		thrift.NewTBinaryProtocolFactoryDefault(),
-		thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory()))
+	RunSocketTestSuite(
+		t,
+		thrift.NewTBinaryProtocolFactoryConf(nil),
+		thrift.NewTTransportFactory(),
+	)
+	RunSocketTestSuite(
+		t,
+		thrift.NewTBinaryProtocolFactoryConf(nil),
+		thrift.NewTBufferedTransportFactory(8912),
+	)
+	RunSocketTestSuite(
+		t,
+		thrift.NewTBinaryProtocolFactoryConf(nil),
+		thrift.NewTFramedTransportFactoryConf(thrift.NewTTransportFactory(), nil),
+	)
 }
 
 // Run test suite using TCompactBinaryProtocol
 func TestTCompactProtocol(t *testing.T) {
-	RunSocketTestSuite(t,
-		thrift.NewTCompactProtocolFactory(),
-		thrift.NewTTransportFactory())
-	RunSocketTestSuite(t,
-		thrift.NewTCompactProtocolFactory(),
-		thrift.NewTBufferedTransportFactory(8912))
-	RunSocketTestSuite(t,
-		thrift.NewTCompactProtocolFactory(),
-		thrift.NewTFramedTransportFactory(thrift.NewTTransportFactory()))
+	RunSocketTestSuite(
+		t,
+		thrift.NewTCompactProtocolFactoryConf(nil),
+		thrift.NewTTransportFactory(),
+	)
+	RunSocketTestSuite(
+		t,
+		thrift.NewTCompactProtocolFactoryConf(nil),
+		thrift.NewTBufferedTransportFactory(8912),
+	)
+	RunSocketTestSuite(
+		t,
+		thrift.NewTCompactProtocolFactoryConf(nil),
+		thrift.NewTFramedTransportFactoryConf(thrift.NewTTransportFactory(), nil),
+	)
 }
diff --git a/lib/go/test/tests/struct_args_rets_test.go b/lib/go/test/tests/struct_args_rets_test.go
index df6b746..1f3d0b2 100644
--- a/lib/go/test/tests/struct_args_rets_test.go
+++ b/lib/go/test/tests/struct_args_rets_test.go
@@ -23,7 +23,9 @@
 	st "github.com/apache/thrift/lib/go/test/gopath/src/servicestest"
 )
 
-//this function is never called, it will fail to compile if check is failed
+// This function is never called, it will fail to compile if check is failed
+//
+//lint:ignore U1000 see above ^
 func staticCheckStructArgsResults() {
 	//Check that struct args and results are passed by reference
 	var sa *st.StructA = &st.StructA{}
diff --git a/lib/go/test/tests/thrifttest_driver.go b/lib/go/test/tests/thrifttest_driver.go
index b351295..29ccd53 100644
--- a/lib/go/test/tests/thrifttest_driver.go
+++ b/lib/go/test/tests/thrifttest_driver.go
@@ -66,7 +66,9 @@
 		"Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, " +
 		"Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa " +
 		"Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, مازِرونی, Bahasa " +
+		//lint:ignore ST1018 intentionally use unicode characters here
 		"Melayu, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, ‪" +
+		//lint:ignore ST1018 intentionally use unicode characters here
 		"Norsk (nynorsk)‬, ‪Norsk (bokmål)‬, Nouormand, Diné bizaad, " +
 		"Occitan, Иронау, Papiamentu, Deitsch, Polski, پنجابی, پښتو, " +
 		"Norfuk / Pitkern, Português, Runa Simi, Rumantsch, Romani, Română, " +
@@ -222,7 +224,7 @@
 	}
 
 	err := client.TestException(defaultCtx, "Xception")
-	if e, ok := err.(*thrifttest.Xception); ok == false || e == nil {
+	if e, ok := err.(*thrifttest.Xception); !ok || e == nil {
 		t.Fatal("TestException Xception failed:", err)
 	} else if e.ErrorCode != 1001 || e.Message != "Xception" {
 		t.Fatal("TestException Xception failed:", e)
diff --git a/lib/go/thrift/application_exception.go b/lib/go/thrift/application_exception.go
index 32d5b01..ed85a64 100644
--- a/lib/go/thrift/application_exception.go
+++ b/lib/go/thrift/application_exception.go
@@ -145,6 +145,9 @@
 
 func (p *tApplicationException) Write(ctx context.Context, oprot TProtocol) (err error) {
 	err = oprot.WriteStructBegin(ctx, "TApplicationException")
+	if err != nil {
+		return
+	}
 	if len(p.Error()) > 0 {
 		err = oprot.WriteFieldBegin(ctx, "message", STRING, 1)
 		if err != nil {
diff --git a/lib/go/thrift/compact_protocol.go b/lib/go/thrift/compact_protocol.go
index e0de077..ff3999c 100644
--- a/lib/go/thrift/compact_protocol.go
+++ b/lib/go/thrift/compact_protocol.go
@@ -334,7 +334,8 @@
 	if e != nil {
 		return NewTProtocolException(e)
 	}
-	if len(value) > 0 {
+	if len(value) == 0 {
+		return nil
 	}
 	_, e = p.trans.WriteString(value)
 	return e
@@ -722,25 +723,12 @@
 	return (n << 1) ^ (n >> 31)
 }
 
-func (p *TCompactProtocol) fixedUint64ToBytes(n uint64, buf []byte) {
-	binary.LittleEndian.PutUint64(buf, n)
-}
-
-func (p *TCompactProtocol) fixedInt64ToBytes(n int64, buf []byte) {
-	binary.LittleEndian.PutUint64(buf, uint64(n))
-}
-
 // Writes a byte without any possibility of all that field header nonsense.
 // Used internally by other writing methods that know they need to write a byte.
 func (p *TCompactProtocol) writeByteDirect(b byte) error {
 	return p.trans.WriteByte(b)
 }
 
-// Writes a byte without any possibility of all that field header nonsense.
-func (p *TCompactProtocol) writeIntAsByteDirect(n int) (int, error) {
-	return 1, p.writeByteDirect(byte(n))
-}
-
 //
 // Internal reading methods
 //
@@ -797,13 +785,6 @@
 // Note that it's important that the mask bytes are long literals,
 // otherwise they'll default to ints, and when you shift an int left 56 bits,
 // you just get a messed up int.
-func (p *TCompactProtocol) bytesToInt64(b []byte) int64 {
-	return int64(binary.LittleEndian.Uint64(b))
-}
-
-// Note that it's important that the mask bytes are long literals,
-// otherwise they'll default to ints, and when you shift an int left 56 bits,
-// you just get a messed up int.
 func (p *TCompactProtocol) bytesToUint64(b []byte) uint64 {
 	return binary.LittleEndian.Uint64(b)
 }
diff --git a/lib/go/thrift/framed_transport.go b/lib/go/thrift/framed_transport.go
index f683e7f..2156dd7 100644
--- a/lib/go/thrift/framed_transport.go
+++ b/lib/go/thrift/framed_transport.go
@@ -200,7 +200,7 @@
 		return err
 	}
 	size := binary.BigEndian.Uint32(buf)
-	if size < 0 || size > uint32(p.cfg.GetMaxFrameSize()) {
+	if size > uint32(p.cfg.GetMaxFrameSize()) {
 		return NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, fmt.Sprintf("Incorrect frame size (%d)", size))
 	}
 	_, err := io.CopyN(&p.readBuf, p.reader, int64(size))
diff --git a/lib/go/thrift/http_client.go b/lib/go/thrift/http_client.go
index 1501586..ce62c96 100644
--- a/lib/go/thrift/http_client.go
+++ b/lib/go/thrift/http_client.go
@@ -36,13 +36,11 @@
 var DefaultHttpClient *http.Client = http.DefaultClient
 
 type THttpClient struct {
-	client             *http.Client
-	response           *http.Response
-	url                *url.URL
-	requestBuffer      *bytes.Buffer
-	header             http.Header
-	nsecConnectTimeout int64
-	nsecReadTimeout    int64
+	client        *http.Client
+	response      *http.Response
+	url           *url.URL
+	requestBuffer *bytes.Buffer
+	header        http.Header
 }
 
 type THttpClientTransportFactory struct {
diff --git a/lib/go/thrift/json_protocol.go b/lib/go/thrift/json_protocol.go
index 98764fa..d248ecf 100644
--- a/lib/go/thrift/json_protocol.go
+++ b/lib/go/thrift/json_protocol.go
@@ -501,44 +501,6 @@
 	return elemType, size, nil
 }
 
-func (p *TJSONProtocol) readElemListBegin() (elemType TType, size int, e error) {
-	if isNull, e := p.ParseListBegin(); isNull || e != nil {
-		return VOID, 0, e
-	}
-	// We don't really use the ctx in ReadString implementation,
-	// so this is safe for now.
-	// We might want to add context to ParseElemListBegin if we start to use
-	// ctx in ReadString implementation in the future.
-	sElemType, err := p.ReadString(context.Background())
-	if err != nil {
-		return VOID, size, err
-	}
-	elemType, err = p.StringToTypeId(sElemType)
-	if err != nil {
-		return elemType, size, err
-	}
-	nSize, _, err2 := p.ParseI64()
-	size = int(nSize)
-	return elemType, size, err2
-}
-
-func (p *TJSONProtocol) writeElemListBegin(elemType TType, size int) error {
-	if e := p.OutputListBegin(); e != nil {
-		return e
-	}
-	s, e1 := p.TypeIdToString(elemType)
-	if e1 != nil {
-		return e1
-	}
-	if e := p.OutputString(s); e != nil {
-		return e
-	}
-	if e := p.OutputI64(int64(size)); e != nil {
-		return e
-	}
-	return nil
-}
-
 func (p *TJSONProtocol) TypeIdToString(fieldType TType) (string, error) {
 	switch byte(fieldType) {
 	case BOOL:
diff --git a/lib/go/thrift/protocol.go b/lib/go/thrift/protocol.go
index 4768c8f..bd76bcc 100644
--- a/lib/go/thrift/protocol.go
+++ b/lib/go/thrift/protocol.go
@@ -174,7 +174,7 @@
 		}
 		return self.ReadListEnd(ctx)
 	default:
-		return NewTProtocolExceptionWithType(INVALID_DATA, errors.New(fmt.Sprintf("Unknown data type %d", fieldType)))
+		return NewTProtocolExceptionWithType(INVALID_DATA, fmt.Errorf("Unknown data type %d", fieldType))
 	}
 	return nil
 }
diff --git a/lib/go/thrift/rich_transport_test.go b/lib/go/thrift/rich_transport_test.go
index 25c3fd5..c516918 100644
--- a/lib/go/thrift/rich_transport_test.go
+++ b/lib/go/thrift/rich_transport_test.go
@@ -62,17 +62,17 @@
 	}
 }
 
-var someError = errors.New("Some error")
+var errSomeError = errors.New("Some error")
 var readByteTests = []struct {
 	r   *mockReader
 	v   byte
 	err error
 }{
-	{&mockReader{0, 55, io.EOF}, 0, io.EOF},        // reader sends EOF w/o data
-	{&mockReader{0, 55, someError}, 0, someError},  // reader sends some other error
-	{&mockReader{1, 55, nil}, 55, nil},             // reader sends data w/o error
-	{&mockReader{1, 55, io.EOF}, 55, nil},          // reader sends data with EOF
-	{&mockReader{1, 55, someError}, 55, someError}, // reader sends data withsome error
+	{&mockReader{0, 55, io.EOF}, 0, io.EOF},              // reader sends EOF w/o data
+	{&mockReader{0, 55, errSomeError}, 0, errSomeError},  // reader sends some other error
+	{&mockReader{1, 55, nil}, 55, nil},                   // reader sends data w/o error
+	{&mockReader{1, 55, io.EOF}, 55, nil},                // reader sends data with EOF
+	{&mockReader{1, 55, errSomeError}, 55, errSomeError}, // reader sends data withsome error
 }
 
 type mockReader struct {
diff --git a/lib/go/thrift/serializer_test.go b/lib/go/thrift/serializer_test.go
index 2e37ea2..9d785f9 100644
--- a/lib/go/thrift/serializer_test.go
+++ b/lib/go/thrift/serializer_test.go
@@ -213,20 +213,18 @@
 }
 
 func TestSerializer(t *testing.T) {
-
-	var protocol_factories map[string]ProtocolFactory
-	protocol_factories = make(map[string]ProtocolFactory)
-	protocol_factories["Binary"] = NewTBinaryProtocolFactoryDefault()
-	protocol_factories["Compact"] = NewTCompactProtocolFactory()
-	//protocol_factories["SimpleJSON"] = NewTSimpleJSONProtocolFactory() - write only, can't be read back by design
-	protocol_factories["JSON"] = NewTJSONProtocolFactory()
+	protocolFactories := make(map[string]ProtocolFactory)
+	protocolFactories["Binary"] = NewTBinaryProtocolFactoryDefault()
+	protocolFactories["Compact"] = NewTCompactProtocolFactory()
+	//protocolFactories["SimpleJSON"] = NewTSimpleJSONProtocolFactory() - write only, can't be read back by design
+	protocolFactories["JSON"] = NewTJSONProtocolFactory()
 
 	tests := make(map[string]func(*testing.T, ProtocolFactory))
 	tests["Test 1"] = ProtocolTest1
 	tests["Test 2"] = ProtocolTest2
 	//tests["Test 3"] = ProtocolTest3 // Example of how to add additional tests
 
-	for name, pf := range protocol_factories {
+	for name, pf := range protocolFactories {
 		t.Run(
 			name,
 			func(t *testing.T) {
@@ -241,7 +239,6 @@
 			},
 		)
 	}
-
 }
 
 func TestSerializerPoolAsync(t *testing.T) {
diff --git a/lib/go/thrift/simple_json_protocol.go b/lib/go/thrift/simple_json_protocol.go
index 4967532..c9c450b 100644
--- a/lib/go/thrift/simple_json_protocol.go
+++ b/lib/go/thrift/simple_json_protocol.go
@@ -173,7 +173,6 @@
 	JSON_INFINITY_BYTES          []byte
 	JSON_NEGATIVE_INFINITY_BYTES []byte
 	JSON_NAN_BYTES               []byte
-	json_nonbase_map_elem_bytes  []byte
 )
 
 func init() {
@@ -194,7 +193,6 @@
 	JSON_INFINITY_BYTES = []byte{'I', 'n', 'f', 'i', 'n', 'i', 't', 'y'}
 	JSON_NEGATIVE_INFINITY_BYTES = []byte{'-', 'I', 'n', 'f', 'i', 'n', 'i', 't', 'y'}
 	JSON_NAN_BYTES = []byte{'N', 'a', 'N'}
-	json_nonbase_map_elem_bytes = []byte{']', ',', '['}
 }
 
 func jsonQuote(s string) string {
@@ -480,7 +478,6 @@
 				e := fmt.Errorf("Expected \"true\" but found: %s", string(b))
 				return value, NewTProtocolExceptionWithType(INVALID_DATA, e)
 			}
-			break
 		case JSON_FALSE[0]:
 			b := make([]byte, len(JSON_FALSE))
 			_, err := p.reader.Read(b)
@@ -493,7 +490,6 @@
 				e := fmt.Errorf("Expected \"false\" but found: %s", string(b))
 				return value, NewTProtocolExceptionWithType(INVALID_DATA, e)
 			}
-			break
 		case JSON_NULL[0]:
 			b := make([]byte, len(JSON_NULL))
 			_, err := p.reader.Read(b)
@@ -903,8 +899,6 @@
 		case ' ', '\r', '\n', '\t':
 			p.reader.ReadByte()
 			continue
-		default:
-			break
 		}
 		break
 	}
@@ -1069,7 +1063,7 @@
 			e := fmt.Errorf("Expecting end of object \"}\", but found: \"%s\"", line)
 			return NewTProtocolExceptionWithType(INVALID_DATA, e)
 		case ' ', '\n', '\r', '\t', '}':
-			break
+			// do nothing
 		}
 	}
 	p.parseContextStack.pop()
@@ -1137,7 +1131,7 @@
 			e := fmt.Errorf("Expecting end of list \"]\", but found: \"%v\"", line)
 			return NewTProtocolExceptionWithType(INVALID_DATA, e)
 		case ' ', '\n', '\r', '\t', rune(JSON_RBRACKET[0]):
-			break
+			// do nothing
 		}
 	}
 	p.parseContextStack.pop()
@@ -1149,82 +1143,6 @@
 	return p.ParsePostValue()
 }
 
-func (p *TSimpleJSONProtocol) readSingleValue() (interface{}, TType, error) {
-	e := p.readNonSignificantWhitespace()
-	if e != nil {
-		return nil, VOID, NewTProtocolException(e)
-	}
-	b, e := p.reader.Peek(1)
-	if len(b) > 0 {
-		c := b[0]
-		switch c {
-		case JSON_NULL[0]:
-			buf := make([]byte, len(JSON_NULL))
-			_, e := p.reader.Read(buf)
-			if e != nil {
-				return nil, VOID, NewTProtocolException(e)
-			}
-			if string(JSON_NULL) != string(buf) {
-				e = mismatch(string(JSON_NULL), string(buf))
-				return nil, VOID, NewTProtocolExceptionWithType(INVALID_DATA, e)
-			}
-			return nil, VOID, nil
-		case JSON_QUOTE:
-			p.reader.ReadByte()
-			v, e := p.ParseStringBody()
-			if e != nil {
-				return v, UTF8, NewTProtocolException(e)
-			}
-			if v == JSON_INFINITY {
-				return INFINITY, DOUBLE, nil
-			} else if v == JSON_NEGATIVE_INFINITY {
-				return NEGATIVE_INFINITY, DOUBLE, nil
-			} else if v == JSON_NAN {
-				return NAN, DOUBLE, nil
-			}
-			return v, UTF8, nil
-		case JSON_TRUE[0]:
-			buf := make([]byte, len(JSON_TRUE))
-			_, e := p.reader.Read(buf)
-			if e != nil {
-				return true, BOOL, NewTProtocolException(e)
-			}
-			if string(JSON_TRUE) != string(buf) {
-				e := mismatch(string(JSON_TRUE), string(buf))
-				return true, BOOL, NewTProtocolExceptionWithType(INVALID_DATA, e)
-			}
-			return true, BOOL, nil
-		case JSON_FALSE[0]:
-			buf := make([]byte, len(JSON_FALSE))
-			_, e := p.reader.Read(buf)
-			if e != nil {
-				return false, BOOL, NewTProtocolException(e)
-			}
-			if string(JSON_FALSE) != string(buf) {
-				e := mismatch(string(JSON_FALSE), string(buf))
-				return false, BOOL, NewTProtocolExceptionWithType(INVALID_DATA, e)
-			}
-			return false, BOOL, nil
-		case JSON_LBRACKET[0]:
-			_, e := p.reader.ReadByte()
-			return make([]interface{}, 0), LIST, NewTProtocolException(e)
-		case JSON_LBRACE[0]:
-			_, e := p.reader.ReadByte()
-			return make(map[string]interface{}), STRUCT, NewTProtocolException(e)
-		case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'e', 'E', '.', '+', '-', JSON_INFINITY[0], JSON_NAN[0]:
-			// assume numeric
-			v, e := p.readNumeric()
-			return v, DOUBLE, e
-		default:
-			e := fmt.Errorf("Expected element in list but found '%s' while parsing JSON.", string(c))
-			return nil, VOID, NewTProtocolExceptionWithType(INVALID_DATA, e)
-		}
-	}
-	e = fmt.Errorf("Cannot read a single element while parsing JSON.")
-	return nil, VOID, NewTProtocolExceptionWithType(INVALID_DATA, e)
-
-}
-
 func (p *TSimpleJSONProtocol) readIfNull() (bool, error) {
 	cont := true
 	for cont {
@@ -1237,10 +1155,8 @@
 			return false, nil
 		case JSON_NULL[0]:
 			cont = false
-			break
 		case ' ', '\n', '\r', '\t':
 			p.reader.ReadByte()
-			break
 		}
 	}
 	if p.safePeekContains(JSON_NULL) {
@@ -1368,8 +1284,6 @@
 		case JSON_QUOTE:
 			if !inQuotes {
 				inQuotes = true
-			} else {
-				break
 			}
 		default:
 			e := fmt.Errorf("Unable to parse number starting with character '%c'", c)
diff --git a/lib/go/thrift/ssl_socket.go b/lib/go/thrift/ssl_socket.go
index cd711ff..bee1097 100644
--- a/lib/go/thrift/ssl_socket.go
+++ b/lib/go/thrift/ssl_socket.go
@@ -42,18 +42,22 @@
 //
 // Example:
 //
-//     trans, err := thrift.NewTSSLSocketConf("localhost:9090", nil, &TConfiguration{
+//     trans := thrift.NewTSSLSocketConf("localhost:9090", &TConfiguration{
 //         ConnectTimeout: time.Second, // Use 0 for no timeout
 //         SocketTimeout:  time.Second, // Use 0 for no timeout
+//
+//         TLSConfig: &tls.Config{
+//             // Fill in tls config here.
+//         }
 //     })
-func NewTSSLSocketConf(hostPort string, conf *TConfiguration) (*TSSLSocket, error) {
+func NewTSSLSocketConf(hostPort string, conf *TConfiguration) *TSSLSocket {
 	if cfg := conf.GetTLSConfig(); cfg != nil && cfg.MinVersion == 0 {
 		cfg.MinVersion = tls.VersionTLS10
 	}
 	return &TSSLSocket{
 		hostPort: hostPort,
 		cfg:      conf,
-	}, nil
+	}
 }
 
 // Deprecated: Use NewTSSLSocketConf instead.
@@ -62,7 +66,7 @@
 		TLSConfig: cfg,
 
 		noPropagation: true,
-	})
+	}), nil
 }
 
 // Deprecated: Use NewTSSLSocketConf instead.
@@ -73,7 +77,7 @@
 		TLSConfig:      cfg,
 
 		noPropagation: true,
-	})
+	}), nil
 }
 
 // NewTSSLSocketFromAddrConf creates a TSSLSocket from a net.Addr.
diff --git a/lib/go/thrift/staticcheck.conf b/lib/go/thrift/staticcheck.conf
new file mode 100644
index 0000000..2ffe850
--- /dev/null
+++ b/lib/go/thrift/staticcheck.conf
@@ -0,0 +1,4 @@
+checks = [
+  "inherit",
+  "-ST1005", # To be consistent with other language libraries we need capitalized error messages.
+]
diff --git a/lib/go/thrift/transport_test.go b/lib/go/thrift/transport_test.go
index 0127803..309cc28 100644
--- a/lib/go/thrift/transport_test.go
+++ b/lib/go/thrift/transport_test.go
@@ -166,12 +166,3 @@
 	}
 	return nil, NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, "Could not find available server port")
 }
-
-func valueInSlice(value string, slice []string) bool {
-	for _, v := range slice {
-		if value == v {
-			return true
-		}
-	}
-	return false
-}