[PATCH] THRIFT-4516: Fix "go vet" warnings for Go 1.10
authorD. Can Celasun <can@dcc.im>
Thu, 15 Mar 2018 11:52:37 +0000 (12:52 +0100)
committerLaszlo Boszormenyi (GCS) <gcs@debian.org>
Tue, 8 Jan 2019 21:31:07 +0000 (21:31 +0000)
Client: go

Gbp-Pq: Name golang_1.10_fix.patch

lib/go/test/dontexportrwtest/compile_test.go
lib/go/thrift/application_exception_test.go
lib/go/thrift/compact_protocol.go
lib/go/thrift/json_protocol_test.go
lib/go/thrift/protocol_test.go
lib/go/thrift/simple_json_protocol.go
lib/go/thrift/simple_json_protocol_test.go
test/go/src/common/clientserver_test.go

index 2b877e3b0ddbacf726f40a596ec795dbc8bb3802..cf6763e297edf93cc117813e5e037e9f29599372 100644 (file)
@@ -20,7 +20,6 @@
 package dontexportrwtest
 
 import (
-       "fmt"
        "testing"
 )
 
@@ -29,10 +28,10 @@ import (
 func TestReadWriteMethodsArePrivate(t *testing.T) {
        // This will only compile if read/write methods exist
        s := NewTestStruct()
-       fmt.Sprintf("%v", s.read)
-       fmt.Sprintf("%v", s.write)
+       _ = s.read
+       _ = s.write
 
        is := NewInnerStruct()
-       fmt.Sprintf("%v", is.read)
-       fmt.Sprintf("%v", is.write)
+       _ = is.read
+       _ = is.write
 }
index b2687a6c847b858a6bb3a6bcdb9a6229f2995a22..77433575d5d75b87259cce8baf0580005bf97b0a 100644 (file)
@@ -29,13 +29,13 @@ func TestTApplicationException(t *testing.T) {
                t.Fatalf("Expected empty string for exception but found '%s'", exc.Error())
        }
        if exc.TypeId() != UNKNOWN_APPLICATION_EXCEPTION {
-               t.Fatalf("Expected type UNKNOWN for exception but found '%s'", exc.TypeId())
+               t.Fatalf("Expected type UNKNOWN for exception but found '%v'", exc.TypeId())
        }
        exc = NewTApplicationException(WRONG_METHOD_NAME, "junk_method")
        if exc.Error() != "junk_method" {
                t.Fatalf("Expected 'junk_method' for exception but found '%s'", exc.Error())
        }
        if exc.TypeId() != WRONG_METHOD_NAME {
-               t.Fatalf("Expected type WRONG_METHOD_NAME for exception but found '%s'", exc.TypeId())
+               t.Fatalf("Expected type WRONG_METHOD_NAME for exception but found '%v'", exc.TypeId())
        }
 }
index 0bc5fddeb38031ebd674a338127475b218af20f8..ffbd4cd1e710cb9385c9a30047428847d3c53506 100644 (file)
@@ -806,7 +806,7 @@ func (p *TCompactProtocol) getTType(t tCompactType) (TType, error) {
        case COMPACT_STRUCT:
                return STRUCT, nil
        }
-       return STOP, TException(fmt.Errorf("don't know what type: %s", t&0x0f))
+       return STOP, TException(fmt.Errorf("don't know what type: %v", t&0x0f))
 }
 
 // Given a TType value, find the appropriate TCompactProtocol.Types constant.
index 7104ce3a02e78bd7e543e5bb56e185f3a8d0a71c..b7539fd5e1ecabf21d948db767f8354c02d714ec 100644 (file)
@@ -590,7 +590,7 @@ func TestWriteJSONProtocolMap(t *testing.T) {
        }
        str := trans.String()
        if str[0] != '[' || str[len(str)-1] != ']' {
-               t.Fatalf("Bad value for %s, wrote: %q, in go: %q", thetype, str, DOUBLE_VALUES)
+               t.Fatalf("Bad value for %s, wrote: %v, in go: %v", thetype, str, DOUBLE_VALUES)
        }
        expectedKeyType, expectedValueType, expectedSize, err := p.ReadMapBegin()
        if err != nil {
index 2573312d1d314a51b189f08641b2ca6e2bceb2d8..3c0548c1884700d10562112b761bf185de1942d8 100644 (file)
@@ -227,17 +227,17 @@ func ReadWriteBool(t testing.TB, p TProtocol, trans TTransport) {
        for k, v := range BOOL_VALUES {
                err = p.WriteBool(v)
                if err != nil {
-                       t.Errorf("%s: %T %T %q Error writing bool in list at index %d: %q", "ReadWriteBool", p, trans, err, k, v)
+                       t.Errorf("%s: %T %T %v Error writing bool in list at index %v: %v", "ReadWriteBool", p, trans, err, k, v)
                }
        }
        p.WriteListEnd()
        if err != nil {
-               t.Errorf("%s: %T %T %q Error writing list end: %q", "ReadWriteBool", p, trans, err, BOOL_VALUES)
+               t.Errorf("%s: %T %T %v Error writing list end: %v", "ReadWriteBool", p, trans, err, BOOL_VALUES)
        }
        p.Flush()
        thetype2, thelen2, err := p.ReadListBegin()
        if err != nil {
-               t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteBool", p, trans, err, BOOL_VALUES)
+               t.Errorf("%s: %T %T %v Error reading list: %v", "ReadWriteBool", p, trans, err, BOOL_VALUES)
        }
        _, ok := p.(*TSimpleJSONProtocol)
        if !ok {
@@ -245,16 +245,16 @@ func ReadWriteBool(t testing.TB, p TProtocol, trans TTransport) {
                        t.Errorf("%s: %T %T type %s != type %s", "ReadWriteBool", p, trans, thetype, thetype2)
                }
                if thelen != thelen2 {
-                       t.Errorf("%s: %T %T len %s != len %s", "ReadWriteBool", p, trans, thelen, thelen2)
+                       t.Errorf("%s: %T %T len %v != len %v", "ReadWriteBool", p, trans, thelen, thelen2)
                }
        }
        for k, v := range BOOL_VALUES {
                value, err := p.ReadBool()
                if err != nil {
-                       t.Errorf("%s: %T %T %q Error reading bool at index %d: %q", "ReadWriteBool", p, trans, err, k, v)
+                       t.Errorf("%s: %T %T %v Error reading bool at index %v: %v", "ReadWriteBool", p, trans, err, k, v)
                }
                if v != value {
-                       t.Errorf("%s: index %d %q %q %q != %q", "ReadWriteBool", k, p, trans, v, value)
+                       t.Errorf("%s: index %v %v %v %v != %v", "ReadWriteBool", k, p, trans, v, value)
                }
        }
        err = p.ReadListEnd()
@@ -294,7 +294,7 @@ func ReadWriteByte(t testing.TB, p TProtocol, trans TTransport) {
                        t.Errorf("%s: %T %T type %s != type %s", "ReadWriteByte", p, trans, thetype, thetype2)
                }
                if thelen != thelen2 {
-                       t.Errorf("%s: %T %T len %s != len %s", "ReadWriteByte", p, trans, thelen, thelen2)
+                       t.Errorf("%s: %T %T len %v != len %v", "ReadWriteByte", p, trans, thelen, thelen2)
                }
        }
        for k, v := range BYTE_VALUES {
@@ -331,7 +331,7 @@ func ReadWriteI16(t testing.TB, p TProtocol, trans TTransport) {
                        t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI16", p, trans, thetype, thetype2)
                }
                if thelen != thelen2 {
-                       t.Errorf("%s: %T %T len %s != len %s", "ReadWriteI16", p, trans, thelen, thelen2)
+                       t.Errorf("%s: %T %T len %v != len %v", "ReadWriteI16", p, trans, thelen, thelen2)
                }
        }
        for k, v := range INT16_VALUES {
@@ -368,7 +368,7 @@ func ReadWriteI32(t testing.TB, p TProtocol, trans TTransport) {
                        t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI32", p, trans, thetype, thetype2)
                }
                if thelen != thelen2 {
-                       t.Errorf("%s: %T %T len %s != len %s", "ReadWriteI32", p, trans, thelen, thelen2)
+                       t.Errorf("%s: %T %T len %v != len %v", "ReadWriteI32", p, trans, thelen, thelen2)
                }
        }
        for k, v := range INT32_VALUES {
@@ -404,7 +404,7 @@ func ReadWriteI64(t testing.TB, p TProtocol, trans TTransport) {
                        t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI64", p, trans, thetype, thetype2)
                }
                if thelen != thelen2 {
-                       t.Errorf("%s: %T %T len %s != len %s", "ReadWriteI64", p, trans, thelen, thelen2)
+                       t.Errorf("%s: %T %T len %v != len %v", "ReadWriteI64", p, trans, thelen, thelen2)
                }
        }
        for k, v := range INT64_VALUES {
@@ -432,25 +432,25 @@ func ReadWriteDouble(t testing.TB, p TProtocol, trans TTransport) {
        p.Flush()
        thetype2, thelen2, err := p.ReadListBegin()
        if err != nil {
-               t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteDouble", p, trans, err, DOUBLE_VALUES)
+               t.Errorf("%s: %T %T %v Error reading list: %v", "ReadWriteDouble", p, trans, err, DOUBLE_VALUES)
        }
        if thetype != thetype2 {
                t.Errorf("%s: %T %T type %s != type %s", "ReadWriteDouble", p, trans, thetype, thetype2)
        }
        if thelen != thelen2 {
-               t.Errorf("%s: %T %T len %s != len %s", "ReadWriteDouble", p, trans, thelen, thelen2)
+               t.Errorf("%s: %T %T len %v != len %v", "ReadWriteDouble", p, trans, thelen, thelen2)
        }
        for k, v := range DOUBLE_VALUES {
                value, err := p.ReadDouble()
                if err != nil {
-                       t.Errorf("%s: %T %T %q Error reading double at index %d: %q", "ReadWriteDouble", p, trans, err, k, v)
+                       t.Errorf("%s: %T %T %q Error reading double at index %d: %v", "ReadWriteDouble", p, trans, err, k, v)
                }
                if math.IsNaN(v) {
                        if !math.IsNaN(value) {
-                               t.Errorf("%s: %T %T math.IsNaN(%q) != math.IsNaN(%q)", "ReadWriteDouble", p, trans, v, value)
+                               t.Errorf("%s: %T %T math.IsNaN(%v) != math.IsNaN(%v)", "ReadWriteDouble", p, trans, v, value)
                        }
                } else if v != value {
-                       t.Errorf("%s: %T %T %v != %q", "ReadWriteDouble", p, trans, v, value)
+                       t.Errorf("%s: %T %T %v != %v", "ReadWriteDouble", p, trans, v, value)
                }
        }
        err = p.ReadListEnd()
@@ -478,7 +478,7 @@ func ReadWriteString(t testing.TB, p TProtocol, trans TTransport) {
                        t.Errorf("%s: %T %T type %s != type %s", "ReadWriteString", p, trans, thetype, thetype2)
                }
                if thelen != thelen2 {
-                       t.Errorf("%s: %T %T len %s != len %s", "ReadWriteString", p, trans, thelen, thelen2)
+                       t.Errorf("%s: %T %T len %v != len %v", "ReadWriteString", p, trans, thelen, thelen2)
                }
        }
        for k, v := range STRING_VALUES {
@@ -487,7 +487,7 @@ func ReadWriteString(t testing.TB, p TProtocol, trans TTransport) {
                        t.Errorf("%s: %T %T %q Error reading string at index %d: %q", "ReadWriteString", p, trans, err, k, v)
                }
                if v != value {
-                       t.Errorf("%s: %T %T %d != %d", "ReadWriteString", p, trans, v, value)
+                       t.Errorf("%s: %T %T %v != %v", "ReadWriteString", p, trans, v, value)
                }
        }
        if err != nil {
index 73533223182cfb83f5411d234f476f231b24e7b1..cf3f7d4a8078d67ee614f41bb7974d0605f19ef7 100644 (file)
@@ -1064,7 +1064,7 @@ func (p *TSimpleJSONProtocol) ParseListEnd() error {
        for _, char := range line {
                switch char {
                default:
-                       e := fmt.Errorf("Expecting end of list \"]\", but found: \"", line, "\"")
+                       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
index 8f0dcc9dfe26dbaa30591af79d6be3ea8b71df7a..a1f7a9488086e4cf4e451a353da3c3d024bdc4d7 100644 (file)
@@ -658,7 +658,7 @@ func TestWriteSimpleJSONProtocolMap(t *testing.T) {
        }
        str := trans.String()
        if str[0] != '[' || str[len(str)-1] != ']' {
-               t.Fatalf("Bad value for %s, wrote: %q, in go: %q", thetype, str, DOUBLE_VALUES)
+               t.Fatalf("Bad value for %s, wrote: %v, in go: %v", thetype, str, DOUBLE_VALUES)
        }
        l := strings.Split(str[1:len(str)-1], ",")
        if len(l) < 3 {
index c4cfd44f30316beb502563f333c48ad4dc2c2ea9..5bb315b072312b048d649c18d481003f82d41916 100644 (file)
@@ -127,12 +127,12 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
        )
        var err error
        if err = client.TestVoid(defaultCtx); err != nil {
-               t.Errorf("Unexpected error in TestVoid() call: ", err)
+               t.Errorf("Unexpected error in TestVoid() call: %s", err)
        }
 
        thing, err := client.TestString(defaultCtx, "thing")
        if err != nil {
-               t.Errorf("Unexpected error in TestString() call: ", err)
+               t.Errorf("Unexpected error in TestString() call: %s", err)
        }
        if thing != "thing" {
                t.Errorf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
@@ -140,22 +140,22 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
 
        bl, err := client.TestBool(defaultCtx, true)
        if err != nil {
-               t.Errorf("Unexpected error in TestBool() call: ", err)
+               t.Errorf("Unexpected error in TestBool() call: %s", err)
        }
        if !bl {
-               t.Errorf("Unexpected TestBool() result expected true, got %f ", bl)
+               t.Errorf("Unexpected TestBool() result expected true, got %v ", bl)
        }
        bl, err = client.TestBool(defaultCtx, false)
        if err != nil {
-               t.Errorf("Unexpected error in TestBool() call: ", err)
+               t.Errorf("Unexpected error in TestBool() call: %s", err)
        }
        if bl {
-               t.Errorf("Unexpected TestBool() result expected false, got %f ", bl)
+               t.Errorf("Unexpected TestBool() result expected false, got %v ", bl)
        }
 
        b, err := client.TestByte(defaultCtx, 42)
        if err != nil {
-               t.Errorf("Unexpected error in TestByte() call: ", err)
+               t.Errorf("Unexpected error in TestByte() call: %s", err)
        }
        if b != 42 {
                t.Errorf("Unexpected TestByte() result expected 42, got %d ", b)
@@ -163,7 +163,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
 
        i32, err := client.TestI32(defaultCtx, 4242)
        if err != nil {
-               t.Errorf("Unexpected error in TestI32() call: ", err)
+               t.Errorf("Unexpected error in TestI32() call: %s", err)
        }
        if i32 != 4242 {
                t.Errorf("Unexpected TestI32() result expected 4242, got %d ", i32)
@@ -171,7 +171,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
 
        i64, err := client.TestI64(defaultCtx, 424242)
        if err != nil {
-               t.Errorf("Unexpected error in TestI64() call: ", err)
+               t.Errorf("Unexpected error in TestI64() call: %s", err)
        }
        if i64 != 424242 {
                t.Errorf("Unexpected TestI64() result expected 424242, got %d ", i64)
@@ -179,7 +179,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
 
        d, err := client.TestDouble(defaultCtx, 42.42)
        if err != nil {
-               t.Errorf("Unexpected error in TestDouble() call: ", err)
+               t.Errorf("Unexpected error in TestDouble() call: %s", err)
        }
        if d != 42.42 {
                t.Errorf("Unexpected TestDouble() result expected 42.42, got %f ", d)
@@ -194,7 +194,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
        xs.I64Thing = 424242
        xsret, err := client.TestStruct(defaultCtx, xs)
        if err != nil {
-               t.Errorf("Unexpected error in TestStruct() call: ", err)
+               t.Errorf("Unexpected error in TestStruct() call: %s", err)
        }
        if *xs != *xsret {
                t.Errorf("Unexpected TestStruct() result expected %#v, got %#v ", xs, xsret)
@@ -204,7 +204,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
        x2.StructThing = xs
        x2ret, err := client.TestNest(defaultCtx, x2)
        if err != nil {
-               t.Errorf("Unexpected error in TestNest() call: ", err)
+               t.Errorf("Unexpected error in TestNest() call: %s", err)
        }
        if !reflect.DeepEqual(x2, x2ret) {
                t.Errorf("Unexpected TestNest() result expected %#v, got %#v ", x2, x2ret)
@@ -213,7 +213,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
        m := map[int32]int32{1: 2, 3: 4, 5: 42}
        mret, err := client.TestMap(defaultCtx, m)
        if err != nil {
-               t.Errorf("Unexpected error in TestMap() call: ", err)
+               t.Errorf("Unexpected error in TestMap() call: %s", err)
        }
        if !reflect.DeepEqual(m, mret) {
                t.Errorf("Unexpected TestMap() result expected %#v, got %#v ", m, mret)
@@ -222,7 +222,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
        sm := map[string]string{"a": "2", "b": "blah", "some": "thing"}
        smret, err := client.TestStringMap(defaultCtx, sm)
        if err != nil {
-               t.Errorf("Unexpected error in TestStringMap() call: ", err)
+               t.Errorf("Unexpected error in TestStringMap() call: %s", err)
        }
        if !reflect.DeepEqual(sm, smret) {
                t.Errorf("Unexpected TestStringMap() result expected %#v, got %#v ", sm, smret)
@@ -231,7 +231,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
        s := []int32{1, 2, 42}
        sret, err := client.TestSet(defaultCtx, s)
        if err != nil {
-               t.Errorf("Unexpected error in TestSet() call: ", err)
+               t.Errorf("Unexpected error in TestSet() call: %s", err)
        }
        // Sets can be in any order, but Go slices are ordered, so reflect.DeepEqual won't work.
        stemp := map[int32]struct{}{}
@@ -247,7 +247,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
        l := []int32{1, 2, 42}
        lret, err := client.TestList(defaultCtx, l)
        if err != nil {
-               t.Errorf("Unexpected error in TestList() call: ", err)
+               t.Errorf("Unexpected error in TestList() call: %s", err)
        }
        if !reflect.DeepEqual(l, lret) {
                t.Errorf("Unexpected TestList() result expected %#v, got %#v ", l, lret)
@@ -255,7 +255,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
 
        eret, err := client.TestEnum(defaultCtx, thrifttest.Numberz_TWO)
        if err != nil {
-               t.Errorf("Unexpected error in TestEnum() call: ", err)
+               t.Errorf("Unexpected error in TestEnum() call: %s", err)
        }
        if eret != thrifttest.Numberz_TWO {
                t.Errorf("Unexpected TestEnum() result expected %#v, got %#v ", thrifttest.Numberz_TWO, eret)
@@ -263,7 +263,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
 
        tret, err := client.TestTypedef(defaultCtx, thrifttest.UserId(42))
        if err != nil {
-               t.Errorf("Unexpected error in TestTypedef() call: ", err)
+               t.Errorf("Unexpected error in TestTypedef() call: %s", err)
        }
        if tret != thrifttest.UserId(42) {
                t.Errorf("Unexpected TestTypedef() result expected %#v, got %#v ", thrifttest.UserId(42), tret)
@@ -271,7 +271,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
 
        mapmap, err := client.TestMapMap(defaultCtx, 42)
        if err != nil {
-               t.Errorf("Unexpected error in TestMapmap() call: ", err)
+               t.Errorf("Unexpected error in TestMapmap() call: %s", err)
        }
        if !reflect.DeepEqual(mapmap, rmapmap) {
                t.Errorf("Unexpected TestMapmap() result expected %#v, got %#v ", rmapmap, mapmap)
@@ -279,7 +279,7 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
 
        xxsret, err := client.TestMulti(defaultCtx, 42, 4242, 424242, map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24))
        if err != nil {
-               t.Errorf("Unexpected error in TestMulti() call: %v", err)
+               t.Errorf("Unexpected error in TestMulti() call: %s", err)
        }
        if !reflect.DeepEqual(xxs, xxsret) {
                t.Errorf("Unexpected TestMulti() result expected %#v, got %#v ", xxs, xxsret)
@@ -323,11 +323,11 @@ func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, h
 
        err = client.TestOneway(defaultCtx, 2)
        if err != nil {
-               t.Errorf("Unexpected error in TestOneway() call: ", err)
+               t.Errorf("Unexpected error in TestOneway() call: %s", err)
        }
 
        //Make sure the connection still alive
        if err = client.TestVoid(defaultCtx); err != nil {
-               t.Errorf("Unexpected error in TestVoid() call: ", err)
+               t.Errorf("Unexpected error in TestVoid() call: %s", err)
        }
 }