THRIFT-4260 Go context generation issue. Context is parameter in Interface not in implementation
Client: Go
Patch: taozle <zhangliyang26@gmail.com>

This closes #1312
diff --git a/test/go/src/bin/testclient/go17.go b/test/go/src/bin/testclient/go17.go
new file mode 100644
index 0000000..a6003a9
--- /dev/null
+++ b/test/go/src/bin/testclient/go17.go
@@ -0,0 +1,26 @@
+// +build go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package main
+
+import "context"
+
+var defaultCtx = context.Background()
diff --git a/test/go/src/bin/testclient/main.go b/test/go/src/bin/testclient/main.go
index 228120b..b34c539 100644
--- a/test/go/src/bin/testclient/main.go
+++ b/test/go/src/bin/testclient/main.go
@@ -63,11 +63,11 @@
 
 func callEverything(client *thrifttest.ThriftTestClient) {
 	var err error
-	if err = client.TestVoid(); err != nil {
+	if err = client.TestVoid(defaultCtx); err != nil {
 		t.Fatalf("Unexpected error in TestVoid() call: ", err)
 	}
 
-	thing, err := client.TestString("thing")
+	thing, err := client.TestString(defaultCtx, "thing")
 	if err != nil {
 		t.Fatalf("Unexpected error in TestString() call: ", err)
 	}
@@ -75,14 +75,14 @@
 		t.Fatalf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
 	}
 
-	bl, err := client.TestBool(true)
+	bl, err := client.TestBool(defaultCtx, true)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestBool() call: ", err)
 	}
 	if !bl {
 		t.Fatalf("Unexpected TestBool() result expected true, got %f ", bl)
 	}
-	bl, err = client.TestBool(false)
+	bl, err = client.TestBool(defaultCtx, false)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestBool() call: ", err)
 	}
@@ -90,7 +90,7 @@
 		t.Fatalf("Unexpected TestBool() result expected false, got %f ", bl)
 	}
 
-	b, err := client.TestByte(42)
+	b, err := client.TestByte(defaultCtx, 42)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestByte() call: ", err)
 	}
@@ -98,7 +98,7 @@
 		t.Fatalf("Unexpected TestByte() result expected 42, got %d ", b)
 	}
 
-	i32, err := client.TestI32(4242)
+	i32, err := client.TestI32(defaultCtx, 4242)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestI32() call: ", err)
 	}
@@ -106,7 +106,7 @@
 		t.Fatalf("Unexpected TestI32() result expected 4242, got %d ", i32)
 	}
 
-	i64, err := client.TestI64(424242)
+	i64, err := client.TestI64(defaultCtx, 424242)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestI64() call: ", err)
 	}
@@ -114,7 +114,7 @@
 		t.Fatalf("Unexpected TestI64() result expected 424242, got %d ", i64)
 	}
 
-	d, err := client.TestDouble(42.42)
+	d, err := client.TestDouble(defaultCtx, 42.42)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestDouble() call: ", err)
 	}
@@ -126,19 +126,19 @@
 	for i := 0; i < 256; i++ {
 		binout[i] = byte(i)
 	}
-	bin, err := client.TestBinary(binout)
+	bin, err := client.TestBinary(defaultCtx, binout)
 	for i := 0; i < 256; i++ {
 		if (binout[i] != bin[i]) {
 			t.Fatalf("Unexpected TestBinary() result expected %d, got %d ", binout[i], bin[i])
 		}
 	}
-	
+
 	xs := thrifttest.NewXtruct()
 	xs.StringThing = "thing"
 	xs.ByteThing = 42
 	xs.I32Thing = 4242
 	xs.I64Thing = 424242
-	xsret, err := client.TestStruct(xs)
+	xsret, err := client.TestStruct(defaultCtx, xs)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestStruct() call: ", err)
 	}
@@ -148,7 +148,7 @@
 
 	x2 := thrifttest.NewXtruct2()
 	x2.StructThing = xs
-	x2ret, err := client.TestNest(x2)
+	x2ret, err := client.TestNest(defaultCtx, x2)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestNest() call: ", err)
 	}
@@ -157,7 +157,7 @@
 	}
 
 	m := map[int32]int32{1: 2, 3: 4, 5: 42}
-	mret, err := client.TestMap(m)
+	mret, err := client.TestMap(defaultCtx, m)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestMap() call: ", err)
 	}
@@ -166,7 +166,7 @@
 	}
 
 	sm := map[string]string{"a": "2", "b": "blah", "some": "thing"}
-	smret, err := client.TestStringMap(sm)
+	smret, err := client.TestStringMap(defaultCtx, sm)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestStringMap() call: ", err)
 	}
@@ -175,7 +175,7 @@
 	}
 
 	s := []int32{1, 2, 42}
-	sret, err := client.TestSet(s)
+	sret, err := client.TestSet(defaultCtx, s)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestSet() call: ", err)
 	}
@@ -191,7 +191,7 @@
 	}
 
 	l := []int32{1, 2, 42}
-	lret, err := client.TestList(l)
+	lret, err := client.TestList(defaultCtx, l)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestList() call: ", err)
 	}
@@ -199,7 +199,7 @@
 		t.Fatalf("Unexpected TestList() result expected %#v, got %#v ", l, lret)
 	}
 
-	eret, err := client.TestEnum(thrifttest.Numberz_TWO)
+	eret, err := client.TestEnum(defaultCtx, thrifttest.Numberz_TWO)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestEnum() call: ", err)
 	}
@@ -207,7 +207,7 @@
 		t.Fatalf("Unexpected TestEnum() result expected %#v, got %#v ", thrifttest.Numberz_TWO, eret)
 	}
 
-	tret, err := client.TestTypedef(thrifttest.UserId(42))
+	tret, err := client.TestTypedef(defaultCtx, thrifttest.UserId(42))
 	if err != nil {
 		t.Fatalf("Unexpected error in TestTypedef() call: ", err)
 	}
@@ -215,7 +215,7 @@
 		t.Fatalf("Unexpected TestTypedef() result expected %#v, got %#v ", thrifttest.UserId(42), tret)
 	}
 
-	mapmap, err := client.TestMapMap(42)
+	mapmap, err := client.TestMapMap(defaultCtx, 42)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestMapMap() call: ", err)
 	}
@@ -242,7 +242,7 @@
 		truck1,
 		truck2,
 	}
-	insanity, err := client.TestInsanity(crazy)
+	insanity, err := client.TestInsanity(defaultCtx, crazy)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestInsanity() call: ", err)
 	}
@@ -261,7 +261,7 @@
 		insanity[2][6])
 	}
 
-	xxsret, err := client.TestMulti(42, 4242, 424242, map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24))
+	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.Fatalf("Unexpected error in TestMulti() call: ", err)
 	}
@@ -269,7 +269,7 @@
 		t.Fatalf("Unexpected TestMulti() result expected %#v, got %#v ", xxs, xxsret)
 	}
 
-	err = client.TestException("Xception")
+	err = client.TestException(defaultCtx, "Xception")
 	if err == nil {
 		t.Fatalf("Expecting exception in TestException() call")
 	}
@@ -277,13 +277,13 @@
 		t.Fatalf("Unexpected TestException() result expected %#v, got %#v ", xcept, err)
 	}
 
-	err = client.TestException("TException")
+	err = client.TestException(defaultCtx, "TException")
 	_, ok := err.(thrift.TApplicationException)
 	if err == nil || !ok {
 		t.Fatalf("Unexpected TestException() result expected ApplicationError, got %#v ", err)
 	}
 
-	ign, err := client.TestMultiException("Xception", "ignoreme")
+	ign, err := client.TestMultiException(defaultCtx, "Xception", "ignoreme")
 	if ign != nil || err == nil {
 		t.Fatalf("Expecting exception in TestMultiException() call")
 	}
@@ -291,7 +291,7 @@
 		t.Fatalf("Unexpected TestMultiException() %#v ", err)
 	}
 
-	ign, err = client.TestMultiException("Xception2", "ignoreme")
+	ign, err = client.TestMultiException(defaultCtx, "Xception2", "ignoreme")
 	if ign != nil || err == nil {
 		t.Fatalf("Expecting exception in TestMultiException() call")
 	}
@@ -301,13 +301,13 @@
 		t.Fatalf("Unexpected TestMultiException() %#v ", err)
 	}
 
-	err = client.TestOneway(2)
+	err = client.TestOneway(defaultCtx, 2)
 	if err != nil {
 		t.Fatalf("Unexpected error in TestOneway() call: ", err)
 	}
 
 	//Make sure the connection still alive
-	if err = client.TestVoid(); err != nil {
+	if err = client.TestVoid(defaultCtx); err != nil {
 		t.Fatalf("Unexpected error in TestVoid() call: ", err)
 	}
 }
diff --git a/test/go/src/bin/testclient/pre_go17.go b/test/go/src/bin/testclient/pre_go17.go
new file mode 100644
index 0000000..10a6fb8
--- /dev/null
+++ b/test/go/src/bin/testclient/pre_go17.go
@@ -0,0 +1,26 @@
+// +build !go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package main
+
+import "golang.org/x/net/context"
+
+var defaultCtx = context.Background()
diff --git a/test/go/src/common/clientserver_test.go b/test/go/src/common/clientserver_test.go
index acc3dba..ecd021f 100644
--- a/test/go/src/common/clientserver_test.go
+++ b/test/go/src/common/clientserver_test.go
@@ -120,11 +120,11 @@
 		handler.EXPECT().TestVoid(gomock.Any()),
 	)
 	var err error
-	if err = client.TestVoid(); err != nil {
+	if err = client.TestVoid(defaultCtx); err != nil {
 		t.Errorf("Unexpected error in TestVoid() call: ", err)
 	}
 
-	thing, err := client.TestString("thing")
+	thing, err := client.TestString(defaultCtx, "thing")
 	if err != nil {
 		t.Errorf("Unexpected error in TestString() call: ", err)
 	}
@@ -132,14 +132,14 @@
 		t.Errorf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
 	}
 
-	bl, err := client.TestBool(true)
+	bl, err := client.TestBool(defaultCtx, true)
 	if err != nil {
 		t.Errorf("Unexpected error in TestBool() call: ", err)
 	}
 	if !bl {
 		t.Errorf("Unexpected TestBool() result expected true, got %f ", bl)
 	}
-	bl, err = client.TestBool(false)
+	bl, err = client.TestBool(defaultCtx, false)
 	if err != nil {
 		t.Errorf("Unexpected error in TestBool() call: ", err)
 	}
@@ -147,7 +147,7 @@
 		t.Errorf("Unexpected TestBool() result expected false, got %f ", bl)
 	}
 
-	b, err := client.TestByte(42)
+	b, err := client.TestByte(defaultCtx, 42)
 	if err != nil {
 		t.Errorf("Unexpected error in TestByte() call: ", err)
 	}
@@ -155,7 +155,7 @@
 		t.Errorf("Unexpected TestByte() result expected 42, got %d ", b)
 	}
 
-	i32, err := client.TestI32(4242)
+	i32, err := client.TestI32(defaultCtx, 4242)
 	if err != nil {
 		t.Errorf("Unexpected error in TestI32() call: ", err)
 	}
@@ -163,7 +163,7 @@
 		t.Errorf("Unexpected TestI32() result expected 4242, got %d ", i32)
 	}
 
-	i64, err := client.TestI64(424242)
+	i64, err := client.TestI64(defaultCtx, 424242)
 	if err != nil {
 		t.Errorf("Unexpected error in TestI64() call: ", err)
 	}
@@ -171,7 +171,7 @@
 		t.Errorf("Unexpected TestI64() result expected 424242, got %d ", i64)
 	}
 
-	d, err := client.TestDouble(42.42)
+	d, err := client.TestDouble(defaultCtx, 42.42)
 	if err != nil {
 		t.Errorf("Unexpected error in TestDouble() call: ", err)
 	}
@@ -186,7 +186,7 @@
 	xs.ByteThing = 42
 	xs.I32Thing = 4242
 	xs.I64Thing = 424242
-	xsret, err := client.TestStruct(xs)
+	xsret, err := client.TestStruct(defaultCtx, xs)
 	if err != nil {
 		t.Errorf("Unexpected error in TestStruct() call: ", err)
 	}
@@ -196,7 +196,7 @@
 
 	x2 := thrifttest.NewXtruct2()
 	x2.StructThing = xs
-	x2ret, err := client.TestNest(x2)
+	x2ret, err := client.TestNest(defaultCtx, x2)
 	if err != nil {
 		t.Errorf("Unexpected error in TestNest() call: ", err)
 	}
@@ -205,7 +205,7 @@
 	}
 
 	m := map[int32]int32{1: 2, 3: 4, 5: 42}
-	mret, err := client.TestMap(m)
+	mret, err := client.TestMap(defaultCtx, m)
 	if err != nil {
 		t.Errorf("Unexpected error in TestMap() call: ", err)
 	}
@@ -214,7 +214,7 @@
 	}
 
 	sm := map[string]string{"a": "2", "b": "blah", "some": "thing"}
-	smret, err := client.TestStringMap(sm)
+	smret, err := client.TestStringMap(defaultCtx, sm)
 	if err != nil {
 		t.Errorf("Unexpected error in TestStringMap() call: ", err)
 	}
@@ -223,7 +223,7 @@
 	}
 
 	s := []int32{1, 2, 42}
-	sret, err := client.TestSet(s)
+	sret, err := client.TestSet(defaultCtx, s)
 	if err != nil {
 		t.Errorf("Unexpected error in TestSet() call: ", err)
 	}
@@ -239,7 +239,7 @@
 	}
 
 	l := []int32{1, 2, 42}
-	lret, err := client.TestList(l)
+	lret, err := client.TestList(defaultCtx, l)
 	if err != nil {
 		t.Errorf("Unexpected error in TestList() call: ", err)
 	}
@@ -247,7 +247,7 @@
 		t.Errorf("Unexpected TestList() result expected %#v, got %#v ", l, lret)
 	}
 
-	eret, err := client.TestEnum(thrifttest.Numberz_TWO)
+	eret, err := client.TestEnum(defaultCtx, thrifttest.Numberz_TWO)
 	if err != nil {
 		t.Errorf("Unexpected error in TestEnum() call: ", err)
 	}
@@ -255,7 +255,7 @@
 		t.Errorf("Unexpected TestEnum() result expected %#v, got %#v ", thrifttest.Numberz_TWO, eret)
 	}
 
-	tret, err := client.TestTypedef(thrifttest.UserId(42))
+	tret, err := client.TestTypedef(defaultCtx, thrifttest.UserId(42))
 	if err != nil {
 		t.Errorf("Unexpected error in TestTypedef() call: ", err)
 	}
@@ -263,7 +263,7 @@
 		t.Errorf("Unexpected TestTypedef() result expected %#v, got %#v ", thrifttest.UserId(42), tret)
 	}
 
-	mapmap, err := client.TestMapMap(42)
+	mapmap, err := client.TestMapMap(defaultCtx, 42)
 	if err != nil {
 		t.Errorf("Unexpected error in TestMapmap() call: ", err)
 	}
@@ -271,7 +271,7 @@
 		t.Errorf("Unexpected TestMapmap() result expected %#v, got %#v ", rmapmap, mapmap)
 	}
 
-	xxsret, err := client.TestMulti(42, 4242, 424242, map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24))
+	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: ", err)
 	}
@@ -279,7 +279,7 @@
 		t.Errorf("Unexpected TestMulti() result expected %#v, got %#v ", xxs, xxsret)
 	}
 
-	err = client.TestException("some")
+	err = client.TestException(defaultCtx, "some")
 	if err == nil {
 		t.Errorf("Expecting exception in TestException() call")
 	}
@@ -288,13 +288,13 @@
 	}
 
 	// TODO: connection is being closed on this
-	err = client.TestException("TException")
+	err = client.TestException(defaultCtx, "TException")
 	tex, ok := err.(thrift.TApplicationException)
 	if err == nil || !ok || tex.TypeId() != thrift.INTERNAL_ERROR {
 		t.Errorf("Unexpected TestException() result expected ApplicationError, got %#v ", err)
 	}
 
-	ign, err := client.TestMultiException("Xception", "ignoreme")
+	ign, err := client.TestMultiException(defaultCtx, "Xception", "ignoreme")
 	if ign != nil || err == nil {
 		t.Errorf("Expecting exception in TestMultiException() call")
 	}
@@ -302,7 +302,7 @@
 		t.Errorf("Unexpected TestMultiException() %#v ", err)
 	}
 
-	ign, err = client.TestMultiException("Xception2", "ignoreme")
+	ign, err = client.TestMultiException(defaultCtx, "Xception2", "ignoreme")
 	if ign != nil || err == nil {
 		t.Errorf("Expecting exception in TestMultiException() call")
 	}
@@ -312,13 +312,13 @@
 		t.Errorf("Unexpected TestMultiException() %#v ", err)
 	}
 
-	err = client.TestOneway(2)
+	err = client.TestOneway(defaultCtx, 2)
 	if err != nil {
 		t.Errorf("Unexpected error in TestOneway() call: ", err)
 	}
 
 	//Make sure the connection still alive
-	if err = client.TestVoid(); err != nil {
+	if err = client.TestVoid(defaultCtx); err != nil {
 		t.Errorf("Unexpected error in TestVoid() call: ", err)
 	}
 }
diff --git a/test/go/src/common/go17.go b/test/go/src/common/go17.go
new file mode 100644
index 0000000..9aca407
--- /dev/null
+++ b/test/go/src/common/go17.go
@@ -0,0 +1,26 @@
+// +build go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package common
+
+import "context"
+
+var defaultCtx = context.Background()
diff --git a/test/go/src/common/pre_go17.go b/test/go/src/common/pre_go17.go
new file mode 100644
index 0000000..6c14579
--- /dev/null
+++ b/test/go/src/common/pre_go17.go
@@ -0,0 +1,26 @@
+// +build !go1.7
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package common
+
+import "golang.org/x/net/context"
+
+var defaultCtx = context.Background()