Update supported go versions
Client: go
With the release of go 1.23, update supported go versions to 1.22+1.23
according to our go support policy.
Also update the code to use the new range loop feature introduced in go
1.22 when appropriate.
Also fix a bug in TSSLServerSocket.Addr that it does not return the
listener address.
diff --git a/test/go/src/common/server.go b/test/go/src/common/server.go
index f48389d..0af2702 100644
--- a/test/go/src/common/server.go
+++ b/test/go/src/common/server.go
@@ -46,10 +46,10 @@
ssl bool,
certPath string,
handler thrifttest.ThriftTest,
-) (thrift.TProcessor, thrift.TServerTransport, thrift.TTransportFactory, thrift.TProtocolFactory, error) {
+) (thrift.TProcessor, thrift.TServerTransport, thrift.TTransportFactory, thrift.TProtocolFactory, string /* addr */, error) {
var err error
- hostPort := fmt.Sprintf("%s:%d", host, port)
+ hostPort := fmt.Sprintf("%s:0", host)
var cfg *thrift.TConfiguration = nil
var protocolFactory thrift.TProtocolFactory
@@ -65,30 +65,54 @@
case "header":
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.NewTDebugProtocolFactoryWithLogger(protocolFactory, "server:", thrift.StdLogger(nil))
}
var serverTransport thrift.TServerTransport
+ var addr string
if ssl {
cfg := new(tls.Config)
if cert, err := tls.LoadX509KeyPair(certPath+"/server.crt", certPath+"/server.key"); err != nil {
- return nil, nil, nil, nil, err
+ return nil, nil, nil, nil, "", err
} else {
cfg.Certificates = append(cfg.Certificates, cert)
}
- serverTransport, err = thrift.NewTSSLServerSocket(hostPort, cfg)
+ transport, transportErr := thrift.NewTSSLServerSocket(hostPort, cfg)
+ if transportErr == nil {
+ listenErr := transport.Listen()
+ if listenErr == nil {
+ serverTransport = transport
+ addr = transport.Addr().String()
+ } else {
+ err = listenErr
+ }
+ } else {
+ err = transportErr
+ }
} else {
if domain_socket != "" {
serverTransport, err = thrift.NewTServerSocket(domain_socket)
+ addr = domain_socket
} else {
- serverTransport, err = thrift.NewTServerSocket(hostPort)
+ transport, transportErr := thrift.NewTServerSocket(hostPort)
+ if transportErr == nil {
+ listenErr := transport.Listen()
+ if listenErr == nil {
+ serverTransport = transport
+ addr = transport.Addr().String()
+ } else {
+ err = listenErr
+ }
+ } else {
+ err = transportErr
+ }
}
}
if err != nil {
- return nil, nil, nil, nil, err
+ return nil, nil, nil, nil, "", err
}
var transportFactory thrift.TTransportFactory
@@ -107,9 +131,9 @@
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)
- return processor, serverTransport, transportFactory, protocolFactory, nil
+ return processor, serverTransport, transportFactory, protocolFactory, addr, nil
}