This is an automated email from the ASF dual-hosted git repository.

yuxuan pushed a commit to branch 0.15.0
in repository https://gitbox.apache.org/repos/asf/thrift.git


The following commit(s) were added to refs/heads/0.15.0 by this push:
     new 5f829f1  go: Fix things staticcheck complains about
5f829f1 is described below

commit 5f829f143c40a125c611d03244b235a6d1a35d47
Author: Yuxuan 'fishy' Wang <[email protected]>
AuthorDate: Thu Aug 26 11:04:27 2021 -0700

    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
---
 CHANGES.md                                         |  2 +-
 compiler/cpp/src/thrift/generate/t_go_generator.cc | 14 ++--
 go.sum                                             |  3 +
 lib/go/test/tests/client_error_test.go             |  4 +
 lib/go/test/tests/multiplexed_protocol_test.go     | 32 ++++----
 lib/go/test/tests/one_way_test.go                  |  8 +-
 lib/go/test/tests/protocols_test.go                | 80 ++++++++++++-------
 lib/go/test/tests/struct_args_rets_test.go         |  4 +-
 lib/go/test/tests/thrifttest_driver.go             |  4 +-
 lib/go/thrift/application_exception.go             |  3 +
 lib/go/thrift/compact_protocol.go                  | 23 +-----
 lib/go/thrift/framed_transport.go                  |  2 +-
 lib/go/thrift/http_client.go                       | 12 ++-
 lib/go/thrift/json_protocol.go                     | 38 ---------
 lib/go/thrift/protocol.go                          |  2 +-
 lib/go/thrift/rich_transport_test.go               | 12 +--
 lib/go/thrift/serializer_test.go                   | 15 ++--
 lib/go/thrift/simple_json_protocol.go              | 90 +---------------------
 lib/go/thrift/ssl_socket.go                        | 14 ++--
 lib/go/thrift/staticcheck.conf                     |  4 +
 lib/go/thrift/transport_test.go                    |  9 ---
 test/go/src/bin/stress/main.go                     |  6 +-
 test/go/src/bin/testclient/main.go                 |  4 +-
 test/go/src/bin/testserver/main.go                 |  1 -
 test/go/src/common/client.go                       | 33 ++++----
 test/go/src/common/clientserver_test.go            |  4 +-
 test/go/src/common/context_test.go                 |  3 +-
 test/go/src/common/printing_handler.go             |  2 +
 test/go/src/common/server.go                       | 21 ++---
 test/go/src/common/simple_handler.go               |  3 +
 tutorial/go/src/client.go                          | 16 +---
 tutorial/go/src/handler.go                         |  6 +-
 tutorial/go/src/main.go                            | 16 ++--
 33 files changed, 197 insertions(+), 293 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index bfd8cb0..2f45c0d 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -15,7 +15,7 @@
 
 - [THRIFT-5381](https://issues.apache.org/jira/browse/THRIFT-5381) - possible 
collisions at VOID type with some 3rd-party libraries on Haxe cpp targets
 - [THRIFT-5396](https://issues.apache.org/jira/browse/THRIFT-5396) - deprecate 
netstd "Async" method postfix
-- [THRIFT-5453](https://issues.apache.org/jira/browse/THRIFT-5453) - go: 
NewTSocketConf no longer returns an error
+- [THRIFT-5453](https://issues.apache.org/jira/browse/THRIFT-5453) - go: 
NewTSocketConf and NewTSSLSocketConf no longer return an error
 
 ### AS3
 
diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc 
b/compiler/cpp/src/thrift/generate/t_go_generator.cc
index 5c052a1..afed5ac 100644
--- a/compiler/cpp/src/thrift/generate/t_go_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc
@@ -1854,7 +1854,7 @@ void t_go_generator::generate_go_struct_writer(ostream& 
out,
     std::string tstruct_name(publicize(tstruct->get_name()));
     out << indent() << "if c := p.CountSetFields" << tstruct_name << "(); c != 
1 {" << endl
         << indent()
-        << "  return fmt.Errorf(\"%T write union: exactly one field must be 
set (%d set).\", p, c)"
+        << "  return fmt.Errorf(\"%T write union: exactly one field must be 
set (%d set)\", p, c)"
         << endl << indent() << "}" << endl;
   }
   out << indent() << "if err := oprot.WriteStructBegin(ctx, \"" << name << 
"\"); err != nil {" << endl;
@@ -2489,6 +2489,7 @@ void t_go_generator::generate_service_remote(t_service* 
tservice) {
   f_remote << indent() << endl;
   f_remote << indent() << "cmd := flag.Arg(0)" << endl;
   f_remote << indent() << "var err error" << endl;
+  f_remote << indent() << "var cfg *thrift.TConfiguration = nil" << endl;
   f_remote << indent() << "if useHttp {" << endl;
   f_remote << indent() << "  trans, err = 
thrift.NewTHttpClient(parsedUrl.String())" << endl;
   f_remote << indent() << "  if len(headers) > 0 {" << endl;
@@ -2507,14 +2508,13 @@ void t_go_generator::generate_service_remote(t_service* 
tservice) {
   f_remote << indent() << "                 os.Exit(1)" << endl;
   f_remote << indent() << "         }" << endl;
   f_remote << indent() << "  }" << endl;
-  f_remote << indent() << "  trans, err = 
thrift.NewTSocket(net.JoinHostPort(host, portStr))"
-           << endl;
+  f_remote << indent() << "  trans = 
thrift.NewTSocketConf(net.JoinHostPort(host, portStr), cfg)" << endl;
   f_remote << indent() << "  if err != nil {" << endl;
   f_remote << indent() << "    fmt.Fprintln(os.Stderr, \"error resolving 
address:\", err)" << endl;
   f_remote << indent() << "    os.Exit(1)" << endl;
   f_remote << indent() << "  }" << endl;
   f_remote << indent() << "  if framed {" << endl;
-  f_remote << indent() << "    trans = thrift.NewTFramedTransport(trans)" << 
endl;
+  f_remote << indent() << "    trans = thrift.NewTFramedTransportConf(trans, 
cfg)" << endl;
   f_remote << indent() << "  }" << endl;
   f_remote << indent() << "}" << endl;
   f_remote << indent() << "if err != nil {" << endl;
@@ -2525,16 +2525,16 @@ void t_go_generator::generate_service_remote(t_service* 
tservice) {
   f_remote << indent() << "var protocolFactory thrift.TProtocolFactory" << 
endl;
   f_remote << indent() << "switch protocol {" << endl;
   f_remote << indent() << "case \"compact\":" << endl;
-  f_remote << indent() << "  protocolFactory = 
thrift.NewTCompactProtocolFactory()" << endl;
+  f_remote << indent() << "  protocolFactory = 
thrift.NewTCompactProtocolFactoryConf(cfg)" << endl;
   f_remote << indent() << "  break" << endl;
   f_remote << indent() << "case \"simplejson\":" << endl;
-  f_remote << indent() << "  protocolFactory = 
thrift.NewTSimpleJSONProtocolFactory()" << endl;
+  f_remote << indent() << "  protocolFactory = 
thrift.NewTSimpleJSONProtocolFactoryConf(cfg)" << endl;
   f_remote << indent() << "  break" << endl;
   f_remote << indent() << "case \"json\":" << endl;
   f_remote << indent() << "  protocolFactory = 
thrift.NewTJSONProtocolFactory()" << endl;
   f_remote << indent() << "  break" << endl;
   f_remote << indent() << "case \"binary\", \"\":" << endl;
-  f_remote << indent() << "  protocolFactory = 
thrift.NewTBinaryProtocolFactoryDefault()" << endl;
+  f_remote << indent() << "  protocolFactory = 
thrift.NewTBinaryProtocolFactoryConf(cfg)" << endl;
   f_remote << indent() << "  break" << endl;
   f_remote << indent() << "default:" << endl;
   f_remote << indent() << "  fmt.Fprintln(os.Stderr, \"Invalid protocol 
specified: \", protocol)"
diff --git a/go.sum b/go.sum
index 646b11a..cfde584 100644
--- a/go.sum
+++ b/go.sum
@@ -2,6 +2,7 @@ github.com/golang/mock v1.5.0 
h1:jlYHihg//f7RRwuPfptm04yp4s7O6Kw8EZiVYIGcH0g=
 github.com/golang/mock v1.5.0/go.mod 
h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod 
h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod 
h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
+golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
 golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod 
h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod 
h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
@@ -9,6 +10,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod 
h1:RxMgew5VJxzue5/jJ
 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod 
h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod 
h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e 
h1:aZzprAO9/8oim3qStq3wc1Xuxx4QmAGriC4VU4ojemQ=
 golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod 
h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod 
h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 
h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod 
h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
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 @@ func prepareClientCallReply(protocol *MockTProtocol, failAt 
int, failWith error)
        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 @@ func prepareClientCallException(protocol *MockTProtocol, 
failAt int, failWith er
        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 (s *SecondImpl) ReturnTwo(ctx context.Context) (r 
int64, err error) {
 }
 
 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 createTransport(addr net.Addr) (thrift.TTransport, 
error) {
 
 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 @@ func TestMultiplexedProtocolFirst(t *testing.T) {
                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 TestMultiplexedProtocolFirst(t *testing.T) {
 
 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 @@ func TestMultiplexedProtocolSecond(t *testing.T) {
                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 TestMultiplexedProtocolSecond(t *testing.T) {
 
 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 @@ func TestMultiplexedProtocolLegacy(t *testing.T) {
        }
        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 @@ func TestMultiplexedProtocolLegacy(t *testing.T) {
        }
        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 TestInitOneway(t *testing.T) {
 }
 
 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 @@ import (
        "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 @@ func RunSocketTestSuite(t *testing.T, protocolFactory 
thrift.TProtocolFactory,
        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 @@ func RunSocketTestSuite(t *testing.T, protocolFactory 
thrift.TProtocolFactory,
 
 // 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 @@ import (
        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 @@ func (p *ThriftTestDriver) Start() {
                "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 @@ func (p *ThriftTestDriver) Start() {
        }
 
        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) Read(ctx context.Context, 
iprot TProtocol) error
 
 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 @@ func (p *TCompactProtocol) WriteString(ctx context.Context, 
value string) error
        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 @@ func (p *TCompactProtocol) int32ToZigzag(n int32) int32 {
        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 @@ func (p *TCompactProtocol) zigzagToInt64(n int64) int64 {
 // 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 @@ func (p *TFramedTransport) readFrame() error {
                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 @@ import (
 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 @@ func (p *TJSONProtocol) ParseElemListBegin() (elemType 
TType, size int, e error)
        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 @@ func Skip(ctx context.Context, self TProtocol, fieldType 
TType, maxDepth int) (e
                }
                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 @@ func TestReadByte(t *testing.T) {
        }
 }
 
-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 ProtocolTest2(t *testing.T, pf ProtocolFactory) {
 }
 
 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 TestSerializer(t *testing.T) {
                        },
                )
        }
-
 }
 
 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 @@ var (
        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 @@ func init() {
        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 @@ func (p *TSimpleJSONProtocol) ReadBool(ctx context.Context) 
(bool, error) {
                                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 @@ func (p *TSimpleJSONProtocol) ReadBool(ctx context.Context) 
(bool, error) {
                                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 @@ func (p *TSimpleJSONProtocol) 
readNonSignificantWhitespace() error {
                case ' ', '\r', '\n', '\t':
                        p.reader.ReadByte()
                        continue
-               default:
-                       break
                }
                break
        }
@@ -1069,7 +1063,7 @@ func (p *TSimpleJSONProtocol) ParseObjectEnd() error {
                        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 @@ func (p *TSimpleJSONProtocol) ParseListEnd() error {
                        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 @@ func (p *TSimpleJSONProtocol) ParseListEnd() error {
        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 @@ func (p *TSimpleJSONProtocol) readIfNull() (bool, error) 
{
                        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 @@ func (p *TSimpleJSONProtocol) readNumeric() (Numeric, 
error) {
                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 @@ type TSSLSocket struct {
 //
 // 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 @@ func NewTSSLSocket(hostPort string, cfg *tls.Config) 
(*TSSLSocket, error) {
                TLSConfig: cfg,
 
                noPropagation: true,
-       })
+       }), nil
 }
 
 // Deprecated: Use NewTSSLSocketConf instead.
@@ -73,7 +77,7 @@ func NewTSSLSocketTimeout(hostPort string, cfg *tls.Config, 
connectTimeout, sock
                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 @@ func FindAvailableTCPServerPort(startPort int) (net.Addr, 
error) {
        }
        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
-}
diff --git a/test/go/src/bin/stress/main.go b/test/go/src/bin/stress/main.go
index 9f32676..3273d1b 100644
--- a/test/go/src/bin/stress/main.go
+++ b/test/go/src/bin/stress/main.go
@@ -103,14 +103,14 @@ func main() {
        var transportFactory thrift.TTransportFactory
 
        if *compact {
-               protocolFactory = thrift.NewTCompactProtocolFactory()
+               protocolFactory = thrift.NewTCompactProtocolFactoryConf(nil)
        } else {
-               protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
+               protocolFactory = thrift.NewTBinaryProtocolFactoryConf(nil)
        }
 
        if *framed {
                transportFactory = thrift.NewTTransportFactory()
-               transportFactory = 
thrift.NewTFramedTransportFactory(transportFactory)
+               transportFactory = 
thrift.NewTFramedTransportFactoryConf(transportFactory, nil)
        } else {
                transportFactory = thrift.NewTBufferedTransportFactory(8192)
        }
diff --git a/test/go/src/bin/testclient/main.go 
b/test/go/src/bin/testclient/main.go
index 39ee95b..f0ce052 100644
--- a/test/go/src/bin/testclient/main.go
+++ b/test/go/src/bin/testclient/main.go
@@ -36,7 +36,6 @@ var domain_socket = flag.String("domain-socket", "", "Domain 
Socket (e.g. /tmp/t
 var transport = flag.String("transport", "buffered", "Transport: buffered, 
framed, http, zlib")
 var protocol = flag.String("protocol", "binary", "Protocol: binary, compact, 
json")
 var ssl = flag.Bool("ssl", false, "Encrypted Transport using SSL")
-var zlib = flag.Bool("zlib", false, "Wrapped Transport using Zlib")
 var testloops = flag.Int("testloops", 1, "Number of Tests")
 
 func main() {
@@ -131,6 +130,9 @@ func callEverything(client *thrifttest.ThriftTestClient) {
                binout[i] = byte(i)
        }
        bin, err := client.TestBinary(defaultCtx, binout)
+       if err != nil {
+               t.Fatalf("TestBinary failed with %v", err)
+       }
        for i := 0; i < 256; i++ {
                if binout[i] != bin[i] {
                        t.Fatalf("Unexpected TestBinary() result expected %d, 
got %d ", binout[i], bin[i])
diff --git a/test/go/src/bin/testserver/main.go 
b/test/go/src/bin/testserver/main.go
index d4bd8b4..011a71d 100644
--- a/test/go/src/bin/testserver/main.go
+++ b/test/go/src/bin/testserver/main.go
@@ -35,7 +35,6 @@ var domain_socket = flag.String("domain-socket", "", "Domain 
Socket (e.g. /tmp/T
 var transport = flag.String("transport", "buffered", "Transport: buffered, 
framed, http, zlib")
 var protocol = flag.String("protocol", "binary", "Protocol: binary, compact, 
json, header")
 var ssl = flag.Bool("ssl", false, "Encrypted Transport using SSL")
-var zlib = flag.Bool("zlib", false, "Wrapped Transport using Zlib")
 var certPath = flag.String("certPath", "keys", "Directory that contains SSL 
certificates")
 
 func main() {
diff --git a/test/go/src/common/client.go b/test/go/src/common/client.go
index 2015035..f9dfcaf 100644
--- a/test/go/src/common/client.go
+++ b/test/go/src/common/client.go
@@ -42,32 +42,35 @@ func StartClient(
        domain_socket string,
        transport string,
        protocol string,
-       ssl bool) (client *thrifttest.ThriftTestClient, trans 
thrift.TTransport, err error) {
-
+       ssl bool,
+) (client *thrifttest.ThriftTestClient, trans thrift.TTransport, err error) {
        hostPort := fmt.Sprintf("%s:%d", host, port)
+       cfg := &thrift.TConfiguration{
+               TLSConfig: &tls.Config{
+                       InsecureSkipVerify: true,
+               },
+       }
 
        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(cfg)
        case "header":
-               protocolFactory = thrift.NewTHeaderProtocolFactory()
+               protocolFactory = thrift.NewTHeaderProtocolFactoryConf(cfg)
        default:
-               return nil, nil, fmt.Errorf("Invalid protocol specified %s", 
protocol)
+               return nil, nil, fmt.Errorf("invalid protocol specified %s", 
protocol)
        }
        if debugClientProtocol {
                protocolFactory = 
thrift.NewTDebugProtocolFactoryWithLogger(protocolFactory, "client:", 
thrift.StdLogger(nil))
        }
        if ssl {
-               trans, err = thrift.NewTSSLSocketConf(hostPort, 
&thrift.TConfiguration{
-                       TLSConfig: &tls.Config{InsecureSkipVerify: true},
-               })
+               trans = thrift.NewTSSLSocketConf(hostPort, cfg)
        } else {
                if domain_socket != "" {
                        trans = thrift.NewTSocketConf(domain_socket, nil)
@@ -85,21 +88,21 @@ func StartClient(
                                TLSClientConfig: 
&tls.Config{InsecureSkipVerify: true},
                        }
                        client := &http.Client{Transport: tr}
-                       trans, err = 
thrift.NewTHttpPostClientWithOptions(fmt.Sprintf("https://%s/";, hostPort), 
thrift.THttpClientOptions{Client: client})
+                       trans, err = 
thrift.NewTHttpClientWithOptions(fmt.Sprintf("https://%s/";, hostPort), 
thrift.THttpClientOptions{Client: client})
                        fmt.Println(hostPort)
                } else {
-                       trans, err = 
thrift.NewTHttpPostClient(fmt.Sprintf("http://%s/";, hostPort))
+                       trans, err = 
thrift.NewTHttpClient(fmt.Sprintf("http://%s/";, hostPort))
                }
        case "framed":
-               trans = thrift.NewTFramedTransport(trans)
+               trans = thrift.NewTFramedTransportConf(trans, cfg)
        case "buffered":
                trans = thrift.NewTBufferedTransport(trans, 8192)
        case "zlib":
                trans, err = thrift.NewTZlibTransport(trans, 
zlib.BestCompression)
        case "":
-               trans = trans
+               // Do nothing
        default:
-               return nil, nil, fmt.Errorf("Invalid transport specified %s", 
transport)
+               return nil, nil, fmt.Errorf("invalid transport specified %s", 
transport)
        }
        if err != nil {
                return nil, nil, err
diff --git a/test/go/src/common/clientserver_test.go 
b/test/go/src/common/clientserver_test.go
index d5e3c43..609086b 100644
--- a/test/go/src/common/clientserver_test.go
+++ b/test/go/src/common/clientserver_test.go
@@ -49,7 +49,6 @@ var units = []test_unit{
 }
 
 func TestAllConnection(t *testing.T) {
-       certPath = "../../../keys"
        wg := &sync.WaitGroup{}
        wg.Add(len(units))
        for _, unit := range units {
@@ -67,6 +66,9 @@ func doUnit(t *testing.T, unit *test_unit) {
        handler := NewMockThriftTest(ctrl)
 
        processor, serverTransport, transportFactory, protocolFactory, err := 
GetServerParams(unit.host, unit.port, unit.domain_socket, unit.transport, 
unit.protocol, unit.ssl, "../../../keys", handler)
+       if err != nil {
+               t.Errorf("GetServerParams failed: %v", err)
+       }
 
        server := thrift.NewTSimpleServer4(processor, serverTransport, 
transportFactory, protocolFactory)
        if err = server.Listen(); err != nil {
diff --git a/test/go/src/common/context_test.go 
b/test/go/src/common/context_test.go
index 3e21a54..c6cbad8 100644
--- a/test/go/src/common/context_test.go
+++ b/test/go/src/common/context_test.go
@@ -40,8 +40,6 @@ func (slowHttpHandler) ServeHTTP(w http.ResponseWriter, r 
*http.Request) {
 }
 
 func TestHttpContextTimeout(t *testing.T) {
-       certPath = "../../../keys"
-
        unit := test_unit{"127.0.0.1", 9096, "", "http", "binary", false}
 
        server := &http.Server{Addr: unit.host + fmt.Sprintf(":%d", unit.port), 
Handler: slowHttpHandler{}}
@@ -56,6 +54,7 @@ func TestHttpContextTimeout(t *testing.T) {
 
        unwrapErr := func(err error) error {
                for {
+                       //lint:ignore S1034 type switch is more appropriate 
here.
                        switch err.(type) {
                        case thrift.TTransportException:
                                err = err.(thrift.TTransportException).Err()
diff --git a/test/go/src/common/printing_handler.go 
b/test/go/src/common/printing_handler.go
index d91dde4..b726373 100644
--- a/test/go/src/common/printing_handler.go
+++ b/test/go/src/common/printing_handler.go
@@ -26,6 +26,7 @@ import (
        "fmt"
        "time"
 
+       //lint:ignore ST1001 allow dot import here
        . "github.com/apache/thrift/test/go/src/gen/thrifttest"
 )
 
@@ -333,6 +334,7 @@ func (p *printingHandler) TestException(ctx 
context.Context, arg string) (err er
                e.Message = arg
                return e
        case "TException":
+               //lint:ignore ST1005 To be consistent with other language 
libraries.
                return errors.New("Just TException")
        }
        return
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 @@ import (
 
 var (
        debugServerProtocol bool
-       certPath            string
 )
 
 func init() {
@@ -46,28 +45,30 @@ func GetServerParams(
        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 @@ func GetServerParams(
                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 @@ func GetServerParams(
        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)
 
diff --git a/test/go/src/common/simple_handler.go 
b/test/go/src/common/simple_handler.go
index 971f17e..fb95457 100644
--- a/test/go/src/common/simple_handler.go
+++ b/test/go/src/common/simple_handler.go
@@ -23,6 +23,7 @@ import (
        "errors"
        "time"
 
+       //lint:ignore ST1001 allow dot import here
        . "github.com/apache/thrift/test/go/src/gen/thrifttest"
 )
 
@@ -104,6 +105,7 @@ func (p *simpleHandler) TestMapMap(hello int32) (r 
map[int32]map[int32]int32, er
 }
 
 func (p *simpleHandler) TestInsanity(argument *Insanity) (r 
map[UserId]map[Numberz]*Insanity, err error) {
+       //lint:ignore ST1005 To be consistent with other language libraries.
        return nil, errors.New("No Insanity")
 }
 
@@ -125,6 +127,7 @@ func (p *simpleHandler) TestException(arg string) (err 
error) {
                e.Message = arg
                return e
        case "TException":
+               //lint:ignore ST1005 To be consistent with other language 
libraries.
                return errors.New("Just TException")
        }
        return
diff --git a/tutorial/go/src/client.go b/tutorial/go/src/client.go
index 8776f9c..f944cf8 100644
--- a/tutorial/go/src/client.go
+++ b/tutorial/go/src/client.go
@@ -21,7 +21,6 @@ package main
 
 import (
        "context"
-       "crypto/tls"
        "fmt"
 
        "github.com/apache/thrift/lib/go/thrift"
@@ -79,21 +78,14 @@ func handleClient(client *tutorial.CalculatorClient) (err 
error) {
        return err
 }
 
-func runClient(transportFactory thrift.TTransportFactory, protocolFactory 
thrift.TProtocolFactory, addr string, secure bool) error {
+func runClient(transportFactory thrift.TTransportFactory, protocolFactory 
thrift.TProtocolFactory, addr string, secure bool, cfg *thrift.TConfiguration) 
error {
        var transport thrift.TTransport
-       var err error
        if secure {
-               cfg := new(tls.Config)
-               cfg.InsecureSkipVerify = true
-               transport, err = thrift.NewTSSLSocket(addr, cfg)
+               transport = thrift.NewTSSLSocketConf(addr, cfg)
        } else {
-               transport, err = thrift.NewTSocket(addr)
+               transport = thrift.NewTSocketConf(addr, cfg)
        }
-       if err != nil {
-               fmt.Println("Error opening socket:", err)
-               return err
-       }
-       transport, err = transportFactory.GetTransport(transport)
+       transport, err := transportFactory.GetTransport(transport)
        if err != nil {
                return err
        }
diff --git a/tutorial/go/src/handler.go b/tutorial/go/src/handler.go
index 7645fc2..a9edd26 100644
--- a/tutorial/go/src/handler.go
+++ b/tutorial/go/src/handler.go
@@ -51,13 +51,10 @@ func (p *CalculatorHandler) Calculate(ctx context.Context, 
logid int32, w *tutor
        switch w.Op {
        case tutorial.Operation_ADD:
                val = w.Num1 + w.Num2
-               break
        case tutorial.Operation_SUBTRACT:
                val = w.Num1 - w.Num2
-               break
        case tutorial.Operation_MULTIPLY:
                val = w.Num1 * w.Num2
-               break
        case tutorial.Operation_DIVIDE:
                if w.Num2 == 0 {
                        ouch := tutorial.NewInvalidOperation()
@@ -67,7 +64,6 @@ func (p *CalculatorHandler) Calculate(ctx context.Context, 
logid int32, w *tutor
                        return
                }
                val = w.Num1 / w.Num2
-               break
        default:
                ouch := tutorial.NewInvalidOperation()
                ouch.WhatOp = int32(w.Op)
@@ -93,7 +89,7 @@ func (p *CalculatorHandler) Calculate(ctx context.Context, 
logid int32, w *tutor
 
 func (p *CalculatorHandler) GetStruct(ctx context.Context, key int32) 
(*shared.SharedStruct, error) {
        fmt.Print("getStruct(", key, ")\n")
-       v, _ := p.log[int(key)]
+       v := p.log[int(key)]
        return v, nil
 }
 
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 @@ package main
  */
 
 import (
+       "crypto/tls"
        "flag"
        "fmt"
        "os"
@@ -47,13 +48,13 @@ func main() {
        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 @@ func main() {
        }
 
        var transportFactory thrift.TTransportFactory
+       cfg := &thrift.TConfiguration{
+               TLSConfig: &tls.Config{
+                       InsecureSkipVerify: true,
+               },
+       }
        if *buffered {
                transportFactory = thrift.NewTBufferedTransportFactory(8192)
        } else {
@@ -68,7 +74,7 @@ func main() {
        }
 
        if *framed {
-               transportFactory = 
thrift.NewTFramedTransportFactory(transportFactory)
+               transportFactory = 
thrift.NewTFramedTransportFactoryConf(transportFactory, cfg)
        }
 
        if *server {
@@ -76,7 +82,7 @@ func main() {
                        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)
                }
        }

Reply via email to