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/bin/stress/main.go b/test/go/src/bin/stress/main.go
index 3273d1b..89e87c4 100644
--- a/test/go/src/bin/stress/main.go
+++ b/test/go/src/bin/stress/main.go
@@ -133,7 +133,7 @@
if *clients != 0 {
ready.Add(*clients + 1)
done.Add(*clients)
- for i := 0; i < *clients; i++ {
+ for range *clients {
go client(protocolFactory)
}
ready.Done()
@@ -170,45 +170,45 @@
ready.Wait()
switch callType {
case echoVoid:
- for i := 0; i < *loop; i++ {
+ for range *loop {
client.EchoVoid(ctx)
atomic.AddInt64(&clicounter, 1)
}
case echoByte:
- for i := 0; i < *loop; i++ {
+ for range *loop {
client.EchoByte(ctx, 42)
atomic.AddInt64(&clicounter, 1)
}
case echoI32:
- for i := 0; i < *loop; i++ {
+ for range *loop {
client.EchoI32(ctx, 4242)
atomic.AddInt64(&clicounter, 1)
}
case echoI64:
- for i := 0; i < *loop; i++ {
+ for range *loop {
client.EchoI64(ctx, 424242)
atomic.AddInt64(&clicounter, 1)
}
case echoString:
- for i := 0; i < *loop; i++ {
+ for range *loop {
client.EchoString(ctx, "TestString")
atomic.AddInt64(&clicounter, 1)
}
case echiList:
l := []int8{-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8}
- for i := 0; i < *loop; i++ {
+ for range *loop {
client.EchoList(ctx, l)
atomic.AddInt64(&clicounter, 1)
}
case echoSet:
s := []int8{-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8}
- for i := 0; i < *loop; i++ {
+ for range *loop {
client.EchoSet(ctx, s)
atomic.AddInt64(&clicounter, 1)
}
case echoMap:
m := map[int8]int8{-10: 10, -9: 9, -8: 8, -7: 7, -6: 6, -5: 5, -4: 4, -3: 3, -2: 2, -1: 1, 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8}
- for i := 0; i < *loop; i++ {
+ for range *loop {
client.EchoMap(ctx, m)
atomic.AddInt64(&clicounter, 1)
}
diff --git a/test/go/src/bin/testclient/main.go b/test/go/src/bin/testclient/main.go
index 95fcd47..a71223c 100644
--- a/test/go/src/bin/testclient/main.go
+++ b/test/go/src/bin/testclient/main.go
@@ -20,8 +20,10 @@
package main
import (
+ "bytes"
"context"
"flag"
+ "fmt"
t "log"
"reflect"
@@ -41,11 +43,15 @@
func main() {
flag.Parse()
- client, _, err := common.StartClient(*host, *port, *domain_socket, *transport, *protocol, *ssl)
+ addr := *domain_socket
+ if addr == "" {
+ addr = fmt.Sprintf("%s:%d", *host, *port)
+ }
+ client, _, err := common.StartClient(addr, *transport, *protocol, *ssl)
if err != nil {
t.Fatalf("Unable to start client: ", err)
}
- for i := 0; i < *testloops; i++ {
+ for range *testloops {
callEverything(client)
}
}
@@ -127,17 +133,15 @@
}
binout := make([]byte, 256)
- for i := 0; i < 256; i++ {
+ for i := range binout {
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])
- }
+ if !bytes.Equal(binout, bin) {
+ t.Fatalf("Unexpected TestBinary() result expected % 02x, got % 02x ", binout, bin)
}
uout := thrift.Tuuid{
diff --git a/test/go/src/bin/testserver/main.go b/test/go/src/bin/testserver/main.go
index 60a764f..652fafa 100644
--- a/test/go/src/bin/testserver/main.go
+++ b/test/go/src/bin/testserver/main.go
@@ -41,7 +41,7 @@
func main() {
flag.Parse()
- processor, serverTransport, transportFactory, protocolFactory, err := common.GetServerParams(*host, *port, *domain_socket, *transport, *protocol, *ssl, *certPath, common.PrintingHandler)
+ processor, serverTransport, transportFactory, protocolFactory, _, err := common.GetServerParams(*host, *port, *domain_socket, *transport, *protocol, *ssl, *certPath, common.PrintingHandler)
if err != nil {
log.Fatalf("Unable to process server params: %v", err)