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/lib/go/test/fuzz/go.mod b/lib/go/test/fuzz/go.mod
index b7ddd5f..f22b622 100644
--- a/lib/go/test/fuzz/go.mod
+++ b/lib/go/test/fuzz/go.mod
@@ -1,6 +1,6 @@
module github.com/apache/thrift/lib/go/test/fuzz
-go 1.21
+go 1.22.0
require github.com/apache/thrift v0.0.0-00010101000000-000000000000
diff --git a/lib/go/test/go.mod b/lib/go/test/go.mod
index 0c032b7..541bffc 100644
--- a/lib/go/test/go.mod
+++ b/lib/go/test/go.mod
@@ -1,6 +1,6 @@
module github.com/apache/thrift/lib/go/test
-go 1.21
+go 1.22.0
require (
github.com/apache/thrift v0.0.0-00010101000000-000000000000
diff --git a/lib/go/test/tests/equals_test.go b/lib/go/test/tests/equals_test.go
index b8adc77..f56d0cb 100644
--- a/lib/go/test/tests/equals_test.go
+++ b/lib/go/test/tests/equals_test.go
@@ -255,7 +255,7 @@
func genInt64Slice(length int) []int64 {
ret := make([]int64, length)
- for i := 0; i < length; i++ {
+ for i := range ret {
ret[i] = int64(length - i)
}
return ret
@@ -263,7 +263,7 @@
func genStringSlice(length int) []string {
ret := make([]string, length)
- for i := 0; i < length; i++ {
+ for i := range ret {
ret[i] = strconv.Itoa(length - i)
}
return ret
@@ -271,7 +271,7 @@
func genBytesSlice(length int) [][]byte {
ret := make([][]byte, length)
- for i := 0; i < length; i++ {
+ for i := range ret {
ret[i] = []byte(strconv.Itoa(length - i))
}
return ret
@@ -279,7 +279,7 @@
func genInt64StringMap(length int) map[int64]string {
ret := make(map[int64]string, length)
- for i := 0; i < length; i++ {
+ for i := range length {
ret[int64(i)] = strconv.Itoa(i)
}
return ret
diff --git a/lib/go/test/tests/string_parse_allocation_test.go b/lib/go/test/tests/string_parse_allocation_test.go
index 12790c4..56163b7 100644
--- a/lib/go/test/tests/string_parse_allocation_test.go
+++ b/lib/go/test/tests/string_parse_allocation_test.go
@@ -42,7 +42,7 @@
b.StopTimer()
numEscapedQuotes := 1000
var sb strings.Builder
- for i := 0; i < numEscapedQuotes; i++ {
+ for range numEscapedQuotes {
sb.WriteString(`\"`)
}
@@ -51,7 +51,7 @@
transport := thrift.NewTMemoryBuffer()
p := thrift.NewTJSONProtocol(transport)
- for i := 0; i < b.N; i++ {
+ for range b.N {
transport.Reset()
transport.WriteString(testString)
transport.Flush(context.Background())
diff --git a/lib/go/test/tests/validate_test.go b/lib/go/test/tests/validate_test.go
index 957a8df..52e059a 100644
--- a/lib/go/test/tests/validate_test.go
+++ b/lib/go/test/tests/validate_test.go
@@ -107,7 +107,7 @@
}
bt = validatetest.NewBasicTest()
bt.Map1 = make(map[string]string)
- for i := 0; i < 11; i++ {
+ for i := range 11 {
bt.Map1[strconv.Itoa(i)] = strconv.Itoa(i)
}
if err := bt.Validate(); err == nil {
@@ -149,7 +149,7 @@
t.Errorf("Error cannot be unwrapped into *ValidationError: %v", err)
}
bt = validatetest.NewBasicTest()
- for i := 0; i < 11; i++ {
+ for range 11 {
bt.Set1 = append(bt.Set1, "0")
}
if err := bt.Validate(); err == nil {
@@ -272,7 +272,7 @@
frt = validatetest.NewFieldReferenceTest()
frt.MaxSize = 8
frt.Map0 = make(map[string]string)
- for i := 0; i < 9; i++ {
+ for i := range 9 {
frt.Map0[strconv.Itoa(i)] = strconv.Itoa(i)
}
if err := frt.Validate(); err == nil {
@@ -289,7 +289,7 @@
}
frt = validatetest.NewFieldReferenceTest()
frt.MaxSize = 8
- for i := 0; i < 9; i++ {
+ for range 9 {
frt.List0 = append(frt.List0, "0")
}
if err := frt.Validate(); err == nil {
@@ -306,7 +306,7 @@
}
frt = validatetest.NewFieldReferenceTest()
frt.MaxSize = 8
- for i := 0; i < 9; i++ {
+ for range 9 {
frt.Set0 = append(frt.Set0, "0")
}
if err := frt.Validate(); err == nil {
diff --git a/lib/go/thrift/binary_protocol_test.go b/lib/go/thrift/binary_protocol_test.go
index 88bfd26..67f9923 100644
--- a/lib/go/thrift/binary_protocol_test.go
+++ b/lib/go/thrift/binary_protocol_test.go
@@ -112,7 +112,7 @@
return func(b *testing.B) {
data := make([]byte, dataSize)
b.ResetTimer()
- for i := 0; i < b.N; i++ {
+ for range b.N {
safeReadBytes(askedSize, bytes.NewReader(data))
}
}
diff --git a/lib/go/thrift/exception.go b/lib/go/thrift/exception.go
index e2f1728..5b4cad9 100644
--- a/lib/go/thrift/exception.go
+++ b/lib/go/thrift/exception.go
@@ -121,20 +121,20 @@
//
// For a endpoint defined in thrift IDL like this:
//
-// service MyService {
-// FooResponse foo(1: FooRequest request) throws (
-// 1: Exception1 error1,
-// 2: Exception2 error2,
-// )
-// }
+// service MyService {
+// FooResponse foo(1: FooRequest request) throws (
+// 1: Exception1 error1,
+// 2: Exception2 error2,
+// )
+// }
//
// The thrift compiler generated go code for the result TStruct would be like:
//
-// type MyServiceFooResult struct {
-// Success *FooResponse `thrift:"success,0" db:"success" json:"success,omitempty"`
-// Error1 *Exception1 `thrift:"error1,1" db:"error1" json:"error1,omitempty"`
-// Error2 *Exception2 `thrift:"error2,2" db:"error2" json:"error2,omitempty"`
-// }
+// type MyServiceFooResult struct {
+// Success *FooResponse `thrift:"success,0" db:"success" json:"success,omitempty"`
+// Error1 *Exception1 `thrift:"error1,1" db:"error1" json:"error1,omitempty"`
+// Error2 *Exception2 `thrift:"error2,2" db:"error2" json:"error2,omitempty"`
+// }
//
// And this function extracts the first non-nil exception out of
// *MyServiceFooResult.
@@ -144,7 +144,7 @@
return nil
}
typ := v.Type()
- for i := 0; i < v.NumField(); i++ {
+ for i := range v.NumField() {
if typ.Field(i).Name == "Success" {
continue
}
diff --git a/lib/go/thrift/framed_transport_test.go b/lib/go/thrift/framed_transport_test.go
index d23ec59..e5aa470 100644
--- a/lib/go/thrift/framed_transport_test.go
+++ b/lib/go/thrift/framed_transport_test.go
@@ -42,7 +42,7 @@
writer := NewTFramedTransport(trans)
t.Run("pair", func(t *testing.T) {
- for i := 0; i < n; i++ {
+ for i := range n {
// write
if _, err := io.Copy(writer, strings.NewReader(content)); err != nil {
t.Fatalf("Failed to write on #%d: %v", i, err)
@@ -64,7 +64,7 @@
t.Run("batched", func(t *testing.T) {
// write
- for i := 0; i < n; i++ {
+ for i := range n {
if _, err := io.Copy(writer, strings.NewReader(content)); err != nil {
t.Fatalf("Failed to write on #%d: %v", i, err)
}
@@ -74,7 +74,7 @@
}
// read
- for i := 0; i < n; i++ {
+ for i := range n {
const (
size = len(content)
)
diff --git a/lib/go/thrift/header_transport.go b/lib/go/thrift/header_transport.go
index 8148796..d6d6416 100644
--- a/lib/go/thrift/header_transport.go
+++ b/lib/go/thrift/header_transport.go
@@ -494,7 +494,7 @@
)
t.frameReader = reader
transformIDs := make([]THeaderTransformID, transformCount)
- for i := 0; i < int(transformCount); i++ {
+ for i := range int(transformCount) {
id, err := hp.readVarint32()
if err != nil {
return err
@@ -536,7 +536,7 @@
if err != nil {
return err
}
- for i := 0; i < int(count); i++ {
+ for range int(count) {
key, err := hp.ReadString(ctx)
if err != nil {
return err
diff --git a/lib/go/thrift/header_transport_test.go b/lib/go/thrift/header_transport_test.go
index 125a5fd..09a0331 100644
--- a/lib/go/thrift/header_transport_test.go
+++ b/lib/go/thrift/header_transport_test.go
@@ -316,7 +316,7 @@
writer := NewTHeaderTransport(trans)
t.Run("pair", func(t *testing.T) {
- for i := 0; i < n; i++ {
+ for i := range n {
// write
if _, err := io.Copy(writer, strings.NewReader(content)); err != nil {
t.Fatalf("Failed to write on #%d: %v", i, err)
@@ -338,7 +338,7 @@
t.Run("batched", func(t *testing.T) {
// write
- for i := 0; i < n; i++ {
+ for i := range n {
if _, err := io.Copy(writer, strings.NewReader(content)); err != nil {
t.Fatalf("Failed to write on #%d: %v", i, err)
}
@@ -348,7 +348,7 @@
}
// read
- for i := 0; i < n; i++ {
+ for i := range n {
const (
size = len(content)
)
diff --git a/lib/go/thrift/json_protocol_test.go b/lib/go/thrift/json_protocol_test.go
index 39e52d1..1680532 100644
--- a/lib/go/thrift/json_protocol_test.go
+++ b/lib/go/thrift/json_protocol_test.go
@@ -451,7 +451,7 @@
if len(v) != len(value) {
t.Fatalf("Bad value for %s value length %v, wrote: %v, received length: %v", thetype, len(value), s, len(v))
}
- for i := 0; i < len(v); i++ {
+ for i := range v {
if v[i] != value[i] {
t.Fatalf("Bad value for %s at index %d value %v, wrote: %v, received: %v", thetype, i, value[i], s, v[i])
}
diff --git a/lib/go/thrift/lowlevel_benchmarks_test.go b/lib/go/thrift/lowlevel_benchmarks_test.go
index e173655..b389388 100644
--- a/lib/go/thrift/lowlevel_benchmarks_test.go
+++ b/lib/go/thrift/lowlevel_benchmarks_test.go
@@ -41,7 +41,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBool(b, p, trans)
}
}
@@ -52,7 +52,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteByte(b, p, trans)
}
}
@@ -63,7 +63,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI16(b, p, trans)
}
}
@@ -74,7 +74,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI32(b, p, trans)
}
}
@@ -84,7 +84,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI64(b, p, trans)
}
}
@@ -94,7 +94,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteDouble(b, p, trans)
}
}
@@ -104,7 +104,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteString(b, p, trans)
}
}
@@ -114,7 +114,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBinary(b, p, trans)
}
}
@@ -125,7 +125,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBool(b, p, trans)
}
}
@@ -136,7 +136,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteByte(b, p, trans)
}
}
@@ -147,7 +147,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI16(b, p, trans)
}
}
@@ -158,7 +158,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI32(b, p, trans)
}
}
@@ -168,7 +168,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI64(b, p, trans)
}
}
@@ -178,7 +178,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteDouble(b, p, trans)
}
}
@@ -188,7 +188,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteString(b, p, trans)
}
}
@@ -198,7 +198,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBinary(b, p, trans)
}
}
@@ -209,7 +209,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBool(b, p, trans)
}
}
@@ -220,7 +220,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteByte(b, p, trans)
}
}
@@ -231,7 +231,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI16(b, p, trans)
}
}
@@ -242,7 +242,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI32(b, p, trans)
}
}
@@ -252,7 +252,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI64(b, p, trans)
}
}
@@ -262,7 +262,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteDouble(b, p, trans)
}
}
@@ -272,7 +272,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteString(b, p, trans)
}
}
@@ -282,7 +282,7 @@
b.Fatal(err)
}
p := binaryProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBinary(b, p, trans)
}
}
@@ -293,7 +293,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBool(b, p, trans)
}
}
@@ -304,7 +304,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteByte(b, p, trans)
}
}
@@ -315,7 +315,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI16(b, p, trans)
}
}
@@ -326,7 +326,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI32(b, p, trans)
}
}
@@ -336,7 +336,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI64(b, p, trans)
}
}
@@ -346,7 +346,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteDouble(b, p, trans)
}
}
@@ -356,7 +356,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteString(b, p, trans)
}
}
@@ -366,7 +366,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBinary(b, p, trans)
}
}
@@ -377,7 +377,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBool(b, p, trans)
}
}
@@ -388,7 +388,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteByte(b, p, trans)
}
}
@@ -399,7 +399,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI16(b, p, trans)
}
}
@@ -410,7 +410,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI32(b, p, trans)
}
}
@@ -420,7 +420,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI64(b, p, trans)
}
}
@@ -430,7 +430,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteDouble(b, p, trans)
}
}
@@ -440,7 +440,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteString(b, p, trans)
}
}
@@ -450,7 +450,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBinary(b, p, trans)
}
}
@@ -461,7 +461,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBool(b, p, trans)
}
}
@@ -472,7 +472,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteByte(b, p, trans)
}
}
@@ -483,7 +483,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI16(b, p, trans)
}
}
@@ -494,7 +494,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI32(b, p, trans)
}
}
@@ -504,7 +504,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteI64(b, p, trans)
}
}
@@ -514,7 +514,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteDouble(b, p, trans)
}
}
@@ -524,7 +524,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteString(b, p, trans)
}
}
@@ -534,7 +534,7 @@
b.Fatal(err)
}
p := compactProtoF.GetProtocol(trans)
- for i := 0; i < b.N; i++ {
+ for range b.N {
ReadWriteBinary(b, p, trans)
}
}
diff --git a/lib/go/thrift/protocol.go b/lib/go/thrift/protocol.go
index 2ee14ca..68cfe4a 100644
--- a/lib/go/thrift/protocol.go
+++ b/lib/go/thrift/protocol.go
@@ -146,7 +146,7 @@
if err != nil {
return err
}
- for i := 0; i < size; i++ {
+ for range size {
err := Skip(ctx, self, keyType, maxDepth-1)
if err != nil {
return err
@@ -163,7 +163,7 @@
if err != nil {
return err
}
- for i := 0; i < size; i++ {
+ for range size {
err := Skip(ctx, self, elemType, maxDepth-1)
if err != nil {
return err
@@ -175,7 +175,7 @@
if err != nil {
return err
}
- for i := 0; i < size; i++ {
+ for range size {
err := Skip(ctx, self, elemType, maxDepth-1)
if err != nil {
return err
diff --git a/lib/go/thrift/protocol_test.go b/lib/go/thrift/protocol_test.go
index 1093c94..4fac801 100644
--- a/lib/go/thrift/protocol_test.go
+++ b/lib/go/thrift/protocol_test.go
@@ -45,7 +45,7 @@
func init() {
protocol_bdata = make([]byte, PROTOCOL_BINARY_DATA_SIZE)
- for i := 0; i < PROTOCOL_BINARY_DATA_SIZE; i++ {
+ for i := range PROTOCOL_BINARY_DATA_SIZE {
protocol_bdata[i] = byte((i + 'a') % 255)
}
BOOL_VALUES = []bool{false, true, false, false, true}
@@ -531,7 +531,7 @@
if len(v) != len(value) {
t.Errorf("%s: %T %T len(v) != len(value)... %d != %d", "ReadWriteBinary", p, trans, len(v), len(value))
} else {
- for i := 0; i < len(v); i++ {
+ for i := range v {
if v[i] != value[i] {
t.Errorf("%s: %T %T %s != %s", "ReadWriteBinary", p, trans, v, value)
}
diff --git a/lib/go/thrift/serializer_test.go b/lib/go/thrift/serializer_test.go
index 425ce06..19879c5 100644
--- a/lib/go/thrift/serializer_test.go
+++ b/lib/go/thrift/serializer_test.go
@@ -328,7 +328,7 @@
b.Run(
c.Label,
func(b *testing.B) {
- for i := 0; i < b.N; i++ {
+ for range b.N {
s := c.Serializer()
m := MyTestStruct{}
str, _ := s.WriteString(context.Background(), &m)
diff --git a/lib/go/thrift/serializer_types_test.go b/lib/go/thrift/serializer_types_test.go
index 4d1e992..d960016 100644
--- a/lib/go/thrift/serializer_types_test.go
+++ b/lib/go/thrift/serializer_types_test.go
@@ -319,7 +319,7 @@
}
tMap := make(map[string]string, size)
p.StringMap = tMap
- for i := 0; i < size; i++ {
+ for range size {
var _key0 string
if v, err := iprot.ReadString(ctx); err != nil {
return PrependError("error reading field 0: ", err)
@@ -347,7 +347,7 @@
}
tSlice := make([]string, 0, size)
p.StringList = tSlice
- for i := 0; i < size; i++ {
+ for range size {
var _elem2 string
if v, err := iprot.ReadString(ctx); err != nil {
return PrependError("error reading field 0: ", err)
@@ -369,7 +369,7 @@
}
tSet := make(map[string]struct{}, size)
p.StringSet = tSet
- for i := 0; i < size; i++ {
+ for range size {
var _elem3 string
if v, err := iprot.ReadString(ctx); err != nil {
return PrependError("error reading field 0: ", err)
diff --git a/lib/go/thrift/simple_json_protocol.go b/lib/go/thrift/simple_json_protocol.go
index f7fe68c..ec12991 100644
--- a/lib/go/thrift/simple_json_protocol.go
+++ b/lib/go/thrift/simple_json_protocol.go
@@ -1306,7 +1306,7 @@
// Safely peeks into the buffer, reading only what is necessary
func (p *TSimpleJSONProtocol) safePeekContains(b []byte) bool {
- for i := 0; i < len(b); i++ {
+ for i := range b {
a, _ := p.reader.Peek(i + 1)
if len(a) < (i+1) || a[i] != b[i] {
return false
diff --git a/lib/go/thrift/simple_json_protocol_test.go b/lib/go/thrift/simple_json_protocol_test.go
index 89753c6..002a231 100644
--- a/lib/go/thrift/simple_json_protocol_test.go
+++ b/lib/go/thrift/simple_json_protocol_test.go
@@ -497,7 +497,7 @@
if len(v) != len(value) {
t.Fatalf("Bad value for %s value length %v, wrote: %v, received length: %v", thetype, len(value), s, len(v))
}
- for i := 0; i < len(v); i++ {
+ for i := range v {
if v[i] != value[i] {
t.Fatalf("Bad value for %s at index %d value %v, wrote: %v, received: %v", thetype, i, value[i], s, v[i])
}
diff --git a/lib/go/thrift/ssl_server_socket.go b/lib/go/thrift/ssl_server_socket.go
index 907afca..3f05ad9 100644
--- a/lib/go/thrift/ssl_server_socket.go
+++ b/lib/go/thrift/ssl_server_socket.go
@@ -93,6 +93,9 @@
}
func (p *TSSLServerSocket) Addr() net.Addr {
+ if p.listener != nil {
+ return p.listener.Addr()
+ }
return p.addr
}
diff --git a/lib/go/thrift/transport_test.go b/lib/go/thrift/transport_test.go
index 309cc28..b6263b8 100644
--- a/lib/go/thrift/transport_test.go
+++ b/lib/go/thrift/transport_test.go
@@ -36,7 +36,7 @@
func init() {
transport_bdata = make([]byte, TRANSPORT_BINARY_DATA_SIZE)
- for i := 0; i < TRANSPORT_BINARY_DATA_SIZE; i++ {
+ for i := range TRANSPORT_BINARY_DATA_SIZE {
transport_bdata[i] = byte((i + 'a') % 255)
}
transport_header = map[string]string{"key": "User-Agent",