THRIFT-4516: Fix "go vet" warnings for Go 1.10
Client: go
diff --git a/LANGUAGES.md b/LANGUAGES.md
index 9bf2cc3..aa63ad5 100644
--- a/LANGUAGES.md
+++ b/LANGUAGES.md
@@ -156,7 +156,7 @@
<td align=left><a href="lib/go/README.md">Go</a></td>
<!-- Since -----------------><td>0.7.0</td>
<!-- Build Systems ---------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td>
-<!-- Language Levels -------><td>1.7.6</td><td>1.9.4</td>
+<!-- Language Levels -------><td>1.7.6</td><td>1.10</td>
<!-- Low-Level Transports --><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cred.png" alt=""/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Transport Wrappers ----><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
<!-- Protocols -------------><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td><td><img src="doc/images/cgrn.png" alt="Yes"/></td>
diff --git a/build/docker/README.md b/build/docker/README.md
index 64a5ff8..89b7b2c 100644
--- a/build/docker/README.md
+++ b/build/docker/README.md
@@ -148,7 +148,7 @@
| delphi | | | Not in CI |
| dotnet | 2.1.4 | 2.1.4 | v2.1.4 SDK uses v2.0.5 Runtime |
| erlang | 18.3 | 20.0.4 | |
-| go | 1.7.6 | 1.9.4 | THRIFT-4516: avoid 1.10 |
+| go | 1.7.6 | 1.10 | |
| haskell | 7.10.3 | 8.0.2 | |
| haxe | 3.2.1 | 3.4.4 | THRIFT-4352: avoid 3.4.2 |
| java | 1.8.0_151 | 1.8.0_151 | |
diff --git a/build/docker/ubuntu-artful/Dockerfile b/build/docker/ubuntu-artful/Dockerfile
index dacaa28..181c0fe 100644
--- a/build/docker/ubuntu-artful/Dockerfile
+++ b/build/docker/ubuntu-artful/Dockerfile
@@ -142,9 +142,9 @@
libglib2.0-dev
# golang
-ENV GOLANG_VERSION 1.9.4
+ENV GOLANG_VERSION 1.10
ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
-ENV GOLANG_DOWNLOAD_SHA256 15b0937615809f87321a457bb1265f946f9f6e736c563d6c5e0bd2c22e44f779
+ENV GOLANG_DOWNLOAD_SHA256 b5a64335f1490277b585832d1f6c7f8c6c11206cba5cd3f771dcb87b98ad1a33
RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz && \
echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - && \
tar -C /usr/local -xzf golang.tar.gz && \
diff --git a/lib/go/test/dontexportrwtest/compile_test.go b/lib/go/test/dontexportrwtest/compile_test.go
index 2b877e3..cf6763e 100644
--- a/lib/go/test/dontexportrwtest/compile_test.go
+++ b/lib/go/test/dontexportrwtest/compile_test.go
@@ -20,7 +20,6 @@
package dontexportrwtest
import (
- "fmt"
"testing"
)
@@ -29,10 +28,10 @@
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
}
diff --git a/lib/go/thrift/application_exception_test.go b/lib/go/thrift/application_exception_test.go
index b2687a6..7743357 100644
--- a/lib/go/thrift/application_exception_test.go
+++ b/lib/go/thrift/application_exception_test.go
@@ -29,13 +29,13 @@
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())
}
}
diff --git a/lib/go/thrift/compact_protocol.go b/lib/go/thrift/compact_protocol.go
index fc1d182..66fbf5c 100644
--- a/lib/go/thrift/compact_protocol.go
+++ b/lib/go/thrift/compact_protocol.go
@@ -807,7 +807,7 @@
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.
diff --git a/lib/go/thrift/json_protocol_test.go b/lib/go/thrift/json_protocol_test.go
index 0902f1b..59c4d64 100644
--- a/lib/go/thrift/json_protocol_test.go
+++ b/lib/go/thrift/json_protocol_test.go
@@ -591,7 +591,7 @@
}
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 {
diff --git a/lib/go/thrift/protocol_test.go b/lib/go/thrift/protocol_test.go
index 2e3b65d..e9118da 100644
--- a/lib/go/thrift/protocol_test.go
+++ b/lib/go/thrift/protocol_test.go
@@ -228,17 +228,17 @@
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(context.Background())
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 {
@@ -246,16 +246,16 @@
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()
@@ -295,7 +295,7 @@
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 {
@@ -332,7 +332,7 @@
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 {
@@ -369,7 +369,7 @@
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 {
@@ -405,7 +405,7 @@
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 {
@@ -433,25 +433,25 @@
p.Flush(context.Background())
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()
@@ -479,7 +479,7 @@
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 {
@@ -488,7 +488,7 @@
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 {
diff --git a/lib/go/thrift/simple_json_protocol.go b/lib/go/thrift/simple_json_protocol.go
index 88f569c..2e8a711 100644
--- a/lib/go/thrift/simple_json_protocol.go
+++ b/lib/go/thrift/simple_json_protocol.go
@@ -1065,7 +1065,7 @@
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
diff --git a/lib/go/thrift/simple_json_protocol_test.go b/lib/go/thrift/simple_json_protocol_test.go
index 49181ab..7b98082 100644
--- a/lib/go/thrift/simple_json_protocol_test.go
+++ b/lib/go/thrift/simple_json_protocol_test.go
@@ -659,7 +659,7 @@
}
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 {
diff --git a/test/go/src/common/clientserver_test.go b/test/go/src/common/clientserver_test.go
index cb1abf7..9f93c4c 100644
--- a/test/go/src/common/clientserver_test.go
+++ b/test/go/src/common/clientserver_test.go
@@ -129,12 +129,12 @@
)
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)
@@ -142,22 +142,22 @@
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)
@@ -165,7 +165,7 @@
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)
@@ -173,7 +173,7 @@
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)
@@ -181,7 +181,7 @@
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)
@@ -196,7 +196,7 @@
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)
@@ -206,7 +206,7 @@
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)
@@ -215,7 +215,7 @@
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)
@@ -224,7 +224,7 @@
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)
@@ -233,7 +233,7 @@
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{}{}
@@ -249,7 +249,7 @@
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)
@@ -257,7 +257,7 @@
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)
@@ -265,7 +265,7 @@
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)
@@ -273,7 +273,7 @@
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)
@@ -281,7 +281,7 @@
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)
@@ -325,11 +325,11 @@
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)
}
}