You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2017/07/22 17:43:37 UTC

[1/2] thrift git commit: THRIFT-4236 Support context in go generated code Client: Go Patch: taozle

Repository: thrift
Updated Branches:
  refs/heads/master 0dd823580 -> c0d384a38


http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/test/go/src/common/mock_handler.go
----------------------------------------------------------------------
diff --git a/test/go/src/common/mock_handler.go b/test/go/src/common/mock_handler.go
index b6738ee..3960e1a 100644
--- a/test/go/src/common/mock_handler.go
+++ b/test/go/src/common/mock_handler.go
@@ -23,267 +23,313 @@
 package common
 
 import (
-	gomock "github.com/golang/mock/gomock"
 	thrifttest "gen/thrifttest"
+	gomock "github.com/golang/mock/gomock"
+	context "golang.org/x/net/context"
 )
 
-// Mock of ThriftTest interface
+// MockThriftTest is a mock of ThriftTest interface
 type MockThriftTest struct {
 	ctrl     *gomock.Controller
-	recorder *_MockThriftTestRecorder
+	recorder *MockThriftTestMockRecorder
 }
 
-// Recorder for MockThriftTest (not exported)
-type _MockThriftTestRecorder struct {
+// MockThriftTestMockRecorder is the mock recorder for MockThriftTest
+type MockThriftTestMockRecorder struct {
 	mock *MockThriftTest
 }
 
+// NewMockThriftTest creates a new mock instance
 func NewMockThriftTest(ctrl *gomock.Controller) *MockThriftTest {
 	mock := &MockThriftTest{ctrl: ctrl}
-	mock.recorder = &_MockThriftTestRecorder{mock}
+	mock.recorder = &MockThriftTestMockRecorder{mock}
 	return mock
 }
 
-func (_m *MockThriftTest) EXPECT() *_MockThriftTestRecorder {
+// EXPECT returns an object that allows the caller to indicate expected use
+func (_m *MockThriftTest) EXPECT() *MockThriftTestMockRecorder {
 	return _m.recorder
 }
 
-func (_m *MockThriftTest) TestBool(_param0 bool) (bool, error) {
-	ret := _m.ctrl.Call(_m, "TestBool", _param0)
-	ret0, _ := ret[0].(bool)
+// TestBinary mocks base method
+func (_m *MockThriftTest) TestBinary(_param0 context.Context, _param1 []byte) ([]byte, error) {
+	ret := _m.ctrl.Call(_m, "TestBinary", _param0, _param1)
+	ret0, _ := ret[0].([]byte)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestBool(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestBool", arg0)
+// TestBinary indicates an expected call of TestBinary
+func (_mr *MockThriftTestMockRecorder) TestBinary(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestBinary", arg0, arg1)
 }
 
-
-func (_m *MockThriftTest) TestByte(_param0 int8) (int8, error) {
-	ret := _m.ctrl.Call(_m, "TestByte", _param0)
-	ret0, _ := ret[0].(int8)
+// TestBool mocks base method
+func (_m *MockThriftTest) TestBool(_param0 context.Context, _param1 bool) (bool, error) {
+	ret := _m.ctrl.Call(_m, "TestBool", _param0, _param1)
+	ret0, _ := ret[0].(bool)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestByte(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestByte", arg0)
+// TestBool indicates an expected call of TestBool
+func (_mr *MockThriftTestMockRecorder) TestBool(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestBool", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestDouble(_param0 float64) (float64, error) {
-	ret := _m.ctrl.Call(_m, "TestDouble", _param0)
-	ret0, _ := ret[0].(float64)
+// TestByte mocks base method
+func (_m *MockThriftTest) TestByte(_param0 context.Context, _param1 int8) (int8, error) {
+	ret := _m.ctrl.Call(_m, "TestByte", _param0, _param1)
+	ret0, _ := ret[0].(int8)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestDouble(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestDouble", arg0)
+// TestByte indicates an expected call of TestByte
+func (_mr *MockThriftTestMockRecorder) TestByte(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestByte", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestBinary(_param0 []byte) ([]byte, error) {
-	ret := _m.ctrl.Call(_m, "TestBinary", _param0)
-	ret0, _ := ret[0].([]byte)
+// TestDouble mocks base method
+func (_m *MockThriftTest) TestDouble(_param0 context.Context, _param1 float64) (float64, error) {
+	ret := _m.ctrl.Call(_m, "TestDouble", _param0, _param1)
+	ret0, _ := ret[0].(float64)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestBinary(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestBinary", arg0)
+// TestDouble indicates an expected call of TestDouble
+func (_mr *MockThriftTestMockRecorder) TestDouble(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestDouble", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestEnum(_param0 thrifttest.Numberz) (thrifttest.Numberz, error) {
-	ret := _m.ctrl.Call(_m, "TestEnum", _param0)
+// TestEnum mocks base method
+func (_m *MockThriftTest) TestEnum(_param0 context.Context, _param1 thrifttest.Numberz) (thrifttest.Numberz, error) {
+	ret := _m.ctrl.Call(_m, "TestEnum", _param0, _param1)
 	ret0, _ := ret[0].(thrifttest.Numberz)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestEnum(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestEnum", arg0)
+// TestEnum indicates an expected call of TestEnum
+func (_mr *MockThriftTestMockRecorder) TestEnum(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestEnum", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestException(_param0 string) error {
-	ret := _m.ctrl.Call(_m, "TestException", _param0)
+// TestException mocks base method
+func (_m *MockThriftTest) TestException(_param0 context.Context, _param1 string) error {
+	ret := _m.ctrl.Call(_m, "TestException", _param0, _param1)
 	ret0, _ := ret[0].(error)
 	return ret0
 }
 
-func (_mr *_MockThriftTestRecorder) TestException(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestException", arg0)
+// TestException indicates an expected call of TestException
+func (_mr *MockThriftTestMockRecorder) TestException(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestException", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestI32(_param0 int32) (int32, error) {
-	ret := _m.ctrl.Call(_m, "TestI32", _param0)
+// TestI32 mocks base method
+func (_m *MockThriftTest) TestI32(_param0 context.Context, _param1 int32) (int32, error) {
+	ret := _m.ctrl.Call(_m, "TestI32", _param0, _param1)
 	ret0, _ := ret[0].(int32)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestI32(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestI32", arg0)
+// TestI32 indicates an expected call of TestI32
+func (_mr *MockThriftTestMockRecorder) TestI32(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestI32", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestI64(_param0 int64) (int64, error) {
-	ret := _m.ctrl.Call(_m, "TestI64", _param0)
+// TestI64 mocks base method
+func (_m *MockThriftTest) TestI64(_param0 context.Context, _param1 int64) (int64, error) {
+	ret := _m.ctrl.Call(_m, "TestI64", _param0, _param1)
 	ret0, _ := ret[0].(int64)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestI64(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestI64", arg0)
+// TestI64 indicates an expected call of TestI64
+func (_mr *MockThriftTestMockRecorder) TestI64(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestI64", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestInsanity(_param0 *thrifttest.Insanity) (map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity, error) {
-	ret := _m.ctrl.Call(_m, "TestInsanity", _param0)
+// TestInsanity mocks base method
+func (_m *MockThriftTest) TestInsanity(_param0 context.Context, _param1 *thrifttest.Insanity) (map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity, error) {
+	ret := _m.ctrl.Call(_m, "TestInsanity", _param0, _param1)
 	ret0, _ := ret[0].(map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestInsanity(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestInsanity", arg0)
+// TestInsanity indicates an expected call of TestInsanity
+func (_mr *MockThriftTestMockRecorder) TestInsanity(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestInsanity", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestList(_param0 []int32) ([]int32, error) {
-	ret := _m.ctrl.Call(_m, "TestList", _param0)
+// TestList mocks base method
+func (_m *MockThriftTest) TestList(_param0 context.Context, _param1 []int32) ([]int32, error) {
+	ret := _m.ctrl.Call(_m, "TestList", _param0, _param1)
 	ret0, _ := ret[0].([]int32)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestList(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestList", arg0)
+// TestList indicates an expected call of TestList
+func (_mr *MockThriftTestMockRecorder) TestList(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestList", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestMap(_param0 map[int32]int32) (map[int32]int32, error) {
-	ret := _m.ctrl.Call(_m, "TestMap", _param0)
+// TestMap mocks base method
+func (_m *MockThriftTest) TestMap(_param0 context.Context, _param1 map[int32]int32) (map[int32]int32, error) {
+	ret := _m.ctrl.Call(_m, "TestMap", _param0, _param1)
 	ret0, _ := ret[0].(map[int32]int32)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestMap(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMap", arg0)
+// TestMap indicates an expected call of TestMap
+func (_mr *MockThriftTestMockRecorder) TestMap(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMap", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestMapMap(_param0 int32) (map[int32]map[int32]int32, error) {
-	ret := _m.ctrl.Call(_m, "TestMapMap", _param0)
+// TestMapMap mocks base method
+func (_m *MockThriftTest) TestMapMap(_param0 context.Context, _param1 int32) (map[int32]map[int32]int32, error) {
+	ret := _m.ctrl.Call(_m, "TestMapMap", _param0, _param1)
 	ret0, _ := ret[0].(map[int32]map[int32]int32)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestMapMap(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMapMap", arg0)
+// TestMapMap indicates an expected call of TestMapMap
+func (_mr *MockThriftTestMockRecorder) TestMapMap(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMapMap", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestMulti(_param0 int8, _param1 int32, _param2 int64, _param3 map[int16]string, _param4 thrifttest.Numberz, _param5 thrifttest.UserId) (*thrifttest.Xtruct, error) {
-	ret := _m.ctrl.Call(_m, "TestMulti", _param0, _param1, _param2, _param3, _param4, _param5)
+// TestMulti mocks base method
+func (_m *MockThriftTest) TestMulti(_param0 context.Context, _param1 int8, _param2 int32, _param3 int64, _param4 map[int16]string, _param5 thrifttest.Numberz, _param6 thrifttest.UserId) (*thrifttest.Xtruct, error) {
+	ret := _m.ctrl.Call(_m, "TestMulti", _param0, _param1, _param2, _param3, _param4, _param5, _param6)
 	ret0, _ := ret[0].(*thrifttest.Xtruct)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestMulti(arg0, arg1, arg2, arg3, arg4, arg5 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMulti", arg0, arg1, arg2, arg3, arg4, arg5)
+// TestMulti indicates an expected call of TestMulti
+func (_mr *MockThriftTestMockRecorder) TestMulti(arg0, arg1, arg2, arg3, arg4, arg5, arg6 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMulti", arg0, arg1, arg2, arg3, arg4, arg5, arg6)
 }
 
-func (_m *MockThriftTest) TestMultiException(_param0 string, _param1 string) (*thrifttest.Xtruct, error) {
-	ret := _m.ctrl.Call(_m, "TestMultiException", _param0, _param1)
+// TestMultiException mocks base method
+func (_m *MockThriftTest) TestMultiException(_param0 context.Context, _param1 string, _param2 string) (*thrifttest.Xtruct, error) {
+	ret := _m.ctrl.Call(_m, "TestMultiException", _param0, _param1, _param2)
 	ret0, _ := ret[0].(*thrifttest.Xtruct)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestMultiException(arg0, arg1 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMultiException", arg0, arg1)
+// TestMultiException indicates an expected call of TestMultiException
+func (_mr *MockThriftTestMockRecorder) TestMultiException(arg0, arg1, arg2 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestMultiException", arg0, arg1, arg2)
 }
 
-func (_m *MockThriftTest) TestNest(_param0 *thrifttest.Xtruct2) (*thrifttest.Xtruct2, error) {
-	ret := _m.ctrl.Call(_m, "TestNest", _param0)
+// TestNest mocks base method
+func (_m *MockThriftTest) TestNest(_param0 context.Context, _param1 *thrifttest.Xtruct2) (*thrifttest.Xtruct2, error) {
+	ret := _m.ctrl.Call(_m, "TestNest", _param0, _param1)
 	ret0, _ := ret[0].(*thrifttest.Xtruct2)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestNest(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestNest", arg0)
+// TestNest indicates an expected call of TestNest
+func (_mr *MockThriftTestMockRecorder) TestNest(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestNest", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestOneway(_param0 int32) error {
-	ret := _m.ctrl.Call(_m, "TestOneway", _param0)
+// TestOneway mocks base method
+func (_m *MockThriftTest) TestOneway(_param0 context.Context, _param1 int32) error {
+	ret := _m.ctrl.Call(_m, "TestOneway", _param0, _param1)
 	ret0, _ := ret[0].(error)
 	return ret0
 }
 
-func (_mr *_MockThriftTestRecorder) TestOneway(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestOneway", arg0)
+// TestOneway indicates an expected call of TestOneway
+func (_mr *MockThriftTestMockRecorder) TestOneway(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestOneway", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestSet(_param0 []int32) ([]int32, error) {
-	ret := _m.ctrl.Call(_m, "TestSet", _param0)
+// TestSet mocks base method
+func (_m *MockThriftTest) TestSet(_param0 context.Context, _param1 []int32) ([]int32, error) {
+	ret := _m.ctrl.Call(_m, "TestSet", _param0, _param1)
 	ret0, _ := ret[0].([]int32)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestSet(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestSet", arg0)
+// TestSet indicates an expected call of TestSet
+func (_mr *MockThriftTestMockRecorder) TestSet(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestSet", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestString(_param0 string) (string, error) {
-	ret := _m.ctrl.Call(_m, "TestString", _param0)
+// TestString mocks base method
+func (_m *MockThriftTest) TestString(_param0 context.Context, _param1 string) (string, error) {
+	ret := _m.ctrl.Call(_m, "TestString", _param0, _param1)
 	ret0, _ := ret[0].(string)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestString(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestString", arg0)
+// TestString indicates an expected call of TestString
+func (_mr *MockThriftTestMockRecorder) TestString(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestString", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestStringMap(_param0 map[string]string) (map[string]string, error) {
-	ret := _m.ctrl.Call(_m, "TestStringMap", _param0)
+// TestStringMap mocks base method
+func (_m *MockThriftTest) TestStringMap(_param0 context.Context, _param1 map[string]string) (map[string]string, error) {
+	ret := _m.ctrl.Call(_m, "TestStringMap", _param0, _param1)
 	ret0, _ := ret[0].(map[string]string)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestStringMap(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestStringMap", arg0)
+// TestStringMap indicates an expected call of TestStringMap
+func (_mr *MockThriftTestMockRecorder) TestStringMap(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestStringMap", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestStruct(_param0 *thrifttest.Xtruct) (*thrifttest.Xtruct, error) {
-	ret := _m.ctrl.Call(_m, "TestStruct", _param0)
+// TestStruct mocks base method
+func (_m *MockThriftTest) TestStruct(_param0 context.Context, _param1 *thrifttest.Xtruct) (*thrifttest.Xtruct, error) {
+	ret := _m.ctrl.Call(_m, "TestStruct", _param0, _param1)
 	ret0, _ := ret[0].(*thrifttest.Xtruct)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestStruct(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestStruct", arg0)
+// TestStruct indicates an expected call of TestStruct
+func (_mr *MockThriftTestMockRecorder) TestStruct(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestStruct", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestTypedef(_param0 thrifttest.UserId) (thrifttest.UserId, error) {
-	ret := _m.ctrl.Call(_m, "TestTypedef", _param0)
+// TestTypedef mocks base method
+func (_m *MockThriftTest) TestTypedef(_param0 context.Context, _param1 thrifttest.UserId) (thrifttest.UserId, error) {
+	ret := _m.ctrl.Call(_m, "TestTypedef", _param0, _param1)
 	ret0, _ := ret[0].(thrifttest.UserId)
 	ret1, _ := ret[1].(error)
 	return ret0, ret1
 }
 
-func (_mr *_MockThriftTestRecorder) TestTypedef(arg0 interface{}) *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestTypedef", arg0)
+// TestTypedef indicates an expected call of TestTypedef
+func (_mr *MockThriftTestMockRecorder) TestTypedef(arg0, arg1 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestTypedef", arg0, arg1)
 }
 
-func (_m *MockThriftTest) TestVoid() error {
-	ret := _m.ctrl.Call(_m, "TestVoid")
+// TestVoid mocks base method
+func (_m *MockThriftTest) TestVoid(_param0 context.Context) error {
+	ret := _m.ctrl.Call(_m, "TestVoid", _param0)
 	ret0, _ := ret[0].(error)
 	return ret0
 }
 
-func (_mr *_MockThriftTestRecorder) TestVoid() *gomock.Call {
-	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestVoid")
+// TestVoid indicates an expected call of TestVoid
+func (_mr *MockThriftTestMockRecorder) TestVoid(arg0 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestVoid", arg0)
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/test/go/src/common/printing_handler.go
----------------------------------------------------------------------
diff --git a/test/go/src/common/printing_handler.go b/test/go/src/common/printing_handler.go
index d4e2be9..c0a2862 100644
--- a/test/go/src/common/printing_handler.go
+++ b/test/go/src/common/printing_handler.go
@@ -1,3 +1,5 @@
+// +build !go1.7
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
@@ -25,6 +27,8 @@ import (
 	"encoding/hex"
 	. "gen/thrifttest"
 	"time"
+
+	"golang.org/x/net/context"
 )
 
 var PrintingHandler = &printingHandler{}
@@ -32,7 +36,7 @@ var PrintingHandler = &printingHandler{}
 type printingHandler struct{}
 
 // Prints "testVoid()" and returns nothing.
-func (p *printingHandler) TestVoid() (err error) {
+func (p *printingHandler) TestVoid(ctx context.Context) (err error) {
 	fmt.Println("testVoid()")
 	return nil
 }
@@ -43,7 +47,7 @@ func (p *printingHandler) TestVoid() (err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestString(thing string) (r string, err error) {
+func (p *printingHandler) TestString(ctx context.Context, thing string) (r string, err error) {
 	fmt.Printf("testString(\"%s\")\n", thing)
 	return thing, nil
 }
@@ -54,7 +58,7 @@ func (p *printingHandler) TestString(thing string) (r string, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestBool(thing bool) (r bool, err error) {
+func (p *printingHandler) TestBool(ctx context.Context, thing bool) (r bool, err error) {
 	fmt.Printf("testBool(%t)\n", thing)
 	return thing, nil
 }
@@ -65,7 +69,7 @@ func (p *printingHandler) TestBool(thing bool) (r bool, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestByte(thing int8) (r int8, err error) {
+func (p *printingHandler) TestByte(ctx context.Context, thing int8) (r int8, err error) {
 	fmt.Printf("testByte(%d)\n", thing)
 	return thing, nil
 }
@@ -76,7 +80,7 @@ func (p *printingHandler) TestByte(thing int8) (r int8, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestI32(thing int32) (r int32, err error) {
+func (p *printingHandler) TestI32(ctx context.Context, thing int32) (r int32, err error) {
 	fmt.Printf("testI32(%d)\n", thing)
 	return thing, nil
 }
@@ -87,7 +91,7 @@ func (p *printingHandler) TestI32(thing int32) (r int32, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestI64(thing int64) (r int64, err error) {
+func (p *printingHandler) TestI64(ctx context.Context, thing int64) (r int64, err error) {
 	fmt.Printf("testI64(%d)\n", thing)
 	return thing, nil
 }
@@ -98,7 +102,7 @@ func (p *printingHandler) TestI64(thing int64) (r int64, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestDouble(thing float64) (r float64, err error) {
+func (p *printingHandler) TestDouble(ctx context.Context, thing float64) (r float64, err error) {
 	fmt.Printf("testDouble(%f)\n", thing)
 	return thing, nil
 }
@@ -109,7 +113,7 @@ func (p *printingHandler) TestDouble(thing float64) (r float64, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestBinary(thing []byte) (r []byte, err error) {
+func (p *printingHandler) TestBinary(ctx context.Context, thing []byte) (r []byte, err error) {
 	fmt.Printf("testBinary(%s)\n", hex.EncodeToString(thing))
 	return thing, nil
 }
@@ -120,7 +124,7 @@ func (p *printingHandler) TestBinary(thing []byte) (r []byte, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestStruct(thing *Xtruct) (r *Xtruct, err error) {
+func (p *printingHandler) TestStruct(ctx context.Context, thing *Xtruct) (r *Xtruct, err error) {
 	fmt.Printf("testStruct({\"%s\", %d, %d, %d})\n", thing.StringThing, thing.ByteThing, thing.I32Thing, thing.I64Thing)
 	return thing, err
 }
@@ -131,7 +135,7 @@ func (p *printingHandler) TestStruct(thing *Xtruct) (r *Xtruct, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestNest(nest *Xtruct2) (r *Xtruct2, err error) {
+func (p *printingHandler) TestNest(ctx context.Context, nest *Xtruct2) (r *Xtruct2, err error) {
 	thing := nest.StructThing
 	fmt.Printf("testNest({%d, {\"%s\", %d, %d, %d}, %d})\n", nest.ByteThing, thing.StringThing, thing.ByteThing, thing.I32Thing, thing.I64Thing, nest.I32Thing)
 	return nest, nil
@@ -144,7 +148,7 @@ func (p *printingHandler) TestNest(nest *Xtruct2) (r *Xtruct2, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestMap(thing map[int32]int32) (r map[int32]int32, err error) {
+func (p *printingHandler) TestMap(ctx context.Context, thing map[int32]int32) (r map[int32]int32, err error) {
 	fmt.Printf("testMap({")
 	first := true
 	for k, v := range thing {
@@ -166,7 +170,7 @@ func (p *printingHandler) TestMap(thing map[int32]int32) (r map[int32]int32, err
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestStringMap(thing map[string]string) (r map[string]string, err error) {
+func (p *printingHandler) TestStringMap(ctx context.Context, thing map[string]string) (r map[string]string, err error) {
 	fmt.Printf("testStringMap({")
 	first := true
 	for k, v := range thing {
@@ -188,7 +192,7 @@ func (p *printingHandler) TestStringMap(thing map[string]string) (r map[string]s
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestSet(thing []int32) (r []int32, err error) {
+func (p *printingHandler) TestSet(ctx context.Context, thing []int32) (r []int32, err error) {
 	fmt.Printf("testSet({")
 	first := true
 	for k, _ := range thing {
@@ -210,7 +214,7 @@ func (p *printingHandler) TestSet(thing []int32) (r []int32, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestList(thing []int32) (r []int32, err error) {
+func (p *printingHandler) TestList(ctx context.Context, thing []int32) (r []int32, err error) {
 	fmt.Printf("testList({")
 	for i, v := range thing {
 		if i != 0 {
@@ -228,7 +232,7 @@ func (p *printingHandler) TestList(thing []int32) (r []int32, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestEnum(thing Numberz) (r Numberz, err error) {
+func (p *printingHandler) TestEnum(ctx context.Context, thing Numberz) (r Numberz, err error) {
 	fmt.Printf("testEnum(%d)\n", thing)
 	return thing, nil
 }
@@ -239,7 +243,7 @@ func (p *printingHandler) TestEnum(thing Numberz) (r Numberz, err error) {
 //
 // Parameters:
 //  - Thing
-func (p *printingHandler) TestTypedef(thing UserId) (r UserId, err error) {
+func (p *printingHandler) TestTypedef(ctx context.Context, thing UserId) (r UserId, err error) {
 	fmt.Printf("testTypedef(%d)\n", thing)
 	return thing, nil
 }
@@ -251,7 +255,7 @@ func (p *printingHandler) TestTypedef(thing UserId) (r UserId, err error) {
 //
 // Parameters:
 //  - Hello
-func (p *printingHandler) TestMapMap(hello int32) (r map[int32]map[int32]int32, err error) {
+func (p *printingHandler) TestMapMap(ctx context.Context, hello int32) (r map[int32]map[int32]int32, err error) {
 	fmt.Printf("testMapMap(%d)\n", hello)
 
 	r = map[int32]map[int32]int32{
@@ -273,7 +277,7 @@ func (p *printingHandler) TestMapMap(hello int32) (r map[int32]map[int32]int32,
 //
 // Parameters:
 //  - Argument
-func (p *printingHandler) TestInsanity(argument *Insanity) (r map[UserId]map[Numberz]*Insanity, err error) {
+func (p *printingHandler) TestInsanity(ctx context.Context, argument *Insanity) (r map[UserId]map[Numberz]*Insanity, err error) {
 	fmt.Printf("testInsanity()\n")
 	r = make(map[UserId]map[Numberz]*Insanity)
 	r[1] = map[Numberz]*Insanity {
@@ -303,7 +307,7 @@ func (p *printingHandler) TestInsanity(argument *Insanity) (r map[UserId]map[Num
 //  - Arg3
 //  - Arg4
 //  - Arg5
-func (p *printingHandler) TestMulti(arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 Numberz, arg5 UserId) (r *Xtruct, err error) {
+func (p *printingHandler) TestMulti(ctx context.Context, arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 Numberz, arg5 UserId) (r *Xtruct, err error) {
 	fmt.Printf("testMulti()\n")
 	r = NewXtruct()
 
@@ -322,7 +326,7 @@ func (p *printingHandler) TestMulti(arg0 int8, arg1 int32, arg2 int64, arg3 map[
 //
 // Parameters:
 //  - Arg
-func (p *printingHandler) TestException(arg string) (err error) {
+func (p *printingHandler) TestException(ctx context.Context, arg string) (err error) {
 	fmt.Printf("testException(%s)\n", arg)
 	switch arg {
 	case "Xception":
@@ -346,7 +350,7 @@ func (p *printingHandler) TestException(arg string) (err error) {
 // Parameters:
 //  - Arg0
 //  - Arg1
-func (p *printingHandler) TestMultiException(arg0 string, arg1 string) (r *Xtruct, err error) {
+func (p *printingHandler) TestMultiException(ctx context.Context, arg0 string, arg1 string) (r *Xtruct, err error) {
 	fmt.Printf("testMultiException(%s, %s)\n", arg0, arg1)
 	switch arg0 {
 
@@ -375,7 +379,7 @@ func (p *printingHandler) TestMultiException(arg0 string, arg1 string) (r *Xtruc
 //
 // Parameters:
 //  - SecondsToSleep
-func (p *printingHandler) TestOneway(secondsToSleep int32) (err error) {
+func (p *printingHandler) TestOneway(ctx context.Context, secondsToSleep int32) (err error) {
 	fmt.Printf("testOneway(%d): Sleeping...\n", secondsToSleep)
 	time.Sleep(time.Second * time.Duration(secondsToSleep))
 	fmt.Printf("testOneway(%d): done sleeping!\n", secondsToSleep)

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/test/go/src/common/printing_handler_go17.go
----------------------------------------------------------------------
diff --git a/test/go/src/common/printing_handler_go17.go b/test/go/src/common/printing_handler_go17.go
new file mode 100644
index 0000000..1efae86
--- /dev/null
+++ b/test/go/src/common/printing_handler_go17.go
@@ -0,0 +1,386 @@
+// +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"
+	"errors"
+	"fmt"
+	"encoding/hex"
+	. "gen/thrifttest"
+	"time"
+)
+
+var PrintingHandler = &printingHandler{}
+
+type printingHandler struct{}
+
+// Prints "testVoid()" and returns nothing.
+func (p *printingHandler) TestVoid(ctx context.Context) (err error) {
+	fmt.Println("testVoid()")
+	return nil
+}
+
+// Prints 'testString("%s")' with thing as '%s'
+// @param string thing - the string to print
+// @return string - returns the string 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestString(ctx context.Context, thing string) (r string, err error) {
+	fmt.Printf("testString(\"%s\")\n", thing)
+	return thing, nil
+}
+
+// Prints 'testBool("%t")' with thing as 'true' or 'false'
+// @param bool thing - the bool to print
+// @return bool - returns the bool 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestBool(ctx context.Context, thing bool) (r bool, err error) {
+	fmt.Printf("testBool(%t)\n", thing)
+	return thing, nil
+}
+
+// Prints 'testByte("%d")' with thing as '%d'
+// @param byte thing - the byte to print
+// @return byte - returns the byte 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestByte(ctx context.Context, thing int8) (r int8, err error) {
+	fmt.Printf("testByte(%d)\n", thing)
+	return thing, nil
+}
+
+// Prints 'testI32("%d")' with thing as '%d'
+// @param i32 thing - the i32 to print
+// @return i32 - returns the i32 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestI32(ctx context.Context, thing int32) (r int32, err error) {
+	fmt.Printf("testI32(%d)\n", thing)
+	return thing, nil
+}
+
+// Prints 'testI64("%d")' with thing as '%d'
+// @param i64 thing - the i64 to print
+// @return i64 - returns the i64 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestI64(ctx context.Context, thing int64) (r int64, err error) {
+	fmt.Printf("testI64(%d)\n", thing)
+	return thing, nil
+}
+
+// Prints 'testDouble("%f")' with thing as '%f'
+// @param double thing - the double to print
+// @return double - returns the double 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestDouble(ctx context.Context, thing float64) (r float64, err error) {
+	fmt.Printf("testDouble(%f)\n", thing)
+	return thing, nil
+}
+
+// Prints 'testBinary("%s")' where '%s' is a hex-formatted string of thing's data
+// @param []byte thing - the binary to print
+// @return []byte - returns the binary 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestBinary(ctx context.Context, thing []byte) (r []byte, err error) {
+	fmt.Printf("testBinary(%s)\n", hex.EncodeToString(thing))
+	return thing, nil
+}
+
+// Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma separated values
+// @param Xtruct thing - the Xtruct to print
+// @return Xtruct - returns the Xtruct 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestStruct(ctx context.Context, thing *Xtruct) (r *Xtruct, err error) {
+	fmt.Printf("testStruct({\"%s\", %d, %d, %d})\n", thing.StringThing, thing.ByteThing, thing.I32Thing, thing.I64Thing)
+	return thing, err
+}
+
+// Prints 'testNest("{%s}")' where thing has been formatted into a string of the nested struct
+// @param Xtruct2 thing - the Xtruct2 to print
+// @return Xtruct2 - returns the Xtruct2 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestNest(ctx context.Context, nest *Xtruct2) (r *Xtruct2, err error) {
+	thing := nest.StructThing
+	fmt.Printf("testNest({%d, {\"%s\", %d, %d, %d}, %d})\n", nest.ByteThing, thing.StringThing, thing.ByteThing, thing.I32Thing, thing.I64Thing, nest.I32Thing)
+	return nest, nil
+}
+
+// Prints 'testMap("{%s")' where thing has been formatted into a string of  'key => value' pairs
+//  separated by commas and new lines
+// @param map<i32,i32> thing - the map<i32,i32> to print
+// @return map<i32,i32> - returns the map<i32,i32> 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestMap(ctx context.Context, thing map[int32]int32) (r map[int32]int32, err error) {
+	fmt.Printf("testMap({")
+	first := true
+	for k, v := range thing {
+		if first {
+			first = false
+		} else {
+			fmt.Printf(", ")
+		}
+		fmt.Printf("%d => %d", k, v)
+	}
+	fmt.Printf("})\n")
+	return thing, nil
+}
+
+// Prints 'testStringMap("{%s}")' where thing has been formatted into a string of  'key => value' pairs
+//  separated by commas and new lines
+// @param map<string,string> thing - the map<string,string> to print
+// @return map<string,string> - returns the map<string,string> 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestStringMap(ctx context.Context, thing map[string]string) (r map[string]string, err error) {
+	fmt.Printf("testStringMap({")
+	first := true
+	for k, v := range thing {
+		if first {
+			first = false
+		} else {
+			fmt.Printf(", ")
+		}
+		fmt.Printf("%s => %s", k, v)
+	}
+	fmt.Printf("})\n")
+	return thing, nil
+}
+
+// Prints 'testSet("{%s}")' where thing has been formatted into a string of  values
+//  separated by commas and new lines
+// @param set<i32> thing - the set<i32> to print
+// @return set<i32> - returns the set<i32> 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestSet(ctx context.Context, thing []int32) (r []int32, err error) {
+	fmt.Printf("testSet({")
+	first := true
+	for k, _ := range thing {
+		if first {
+			first = false
+		} else {
+			fmt.Printf(", ")
+		}
+		fmt.Printf("%d", k)
+	}
+	fmt.Printf("})\n")
+	return thing, nil
+}
+
+// Prints 'testList("{%s}")' where thing has been formatted into a string of  values
+//  separated by commas and new lines
+// @param list<i32> thing - the list<i32> to print
+// @return list<i32> - returns the list<i32> 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestList(ctx context.Context, thing []int32) (r []int32, err error) {
+	fmt.Printf("testList({")
+	for i, v := range thing {
+		if i != 0 {
+			fmt.Printf(", ")
+		}
+		fmt.Printf("%d", v)
+	}
+	fmt.Printf("})\n")
+	return thing, nil
+}
+
+// Prints 'testEnum("%d")' where thing has been formatted into it's numeric value
+// @param Numberz thing - the Numberz to print
+// @return Numberz - returns the Numberz 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestEnum(ctx context.Context, thing Numberz) (r Numberz, err error) {
+	fmt.Printf("testEnum(%d)\n", thing)
+	return thing, nil
+}
+
+// Prints 'testTypedef("%d")' with thing as '%d'
+// @param UserId thing - the UserId to print
+// @return UserId - returns the UserId 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestTypedef(ctx context.Context, thing UserId) (r UserId, err error) {
+	fmt.Printf("testTypedef(%d)\n", thing)
+	return thing, nil
+}
+
+// Prints 'testMapMap("%d")' with hello as '%d'
+// @param i32 hello - the i32 to print
+// @return map<i32,map<i32,i32>> - returns a dictionary with these values:
+//   {-4 => {-4 => -4, -3 => -3, -2 => -2, -1 => -1, }, 4 => {1 => 1, 2 => 2, 3 => 3, 4 => 4, }, }
+//
+// Parameters:
+//  - Hello
+func (p *printingHandler) TestMapMap(ctx context.Context, hello int32) (r map[int32]map[int32]int32, err error) {
+	fmt.Printf("testMapMap(%d)\n", hello)
+
+	r = map[int32]map[int32]int32{
+		-4: map[int32]int32{-4: -4, -3: -3, -2: -2, -1: -1},
+		4:  map[int32]int32{4: 4, 3: 3, 2: 2, 1: 1},
+	}
+	return
+}
+
+// So you think you've got this all worked, out eh?
+//
+// Creates a the returned map with these values and prints it out:
+//   { 1 => { 2 => argument,
+//            3 => argument,
+//          },
+//     2 => { 6 => <empty Insanity struct>, },
+//   }
+// @return map<UserId, map<Numberz,Insanity>> - a map with the above values
+//
+// Parameters:
+//  - Argument
+func (p *printingHandler) TestInsanity(ctx context.Context, argument *Insanity) (r map[UserId]map[Numberz]*Insanity, err error) {
+	fmt.Printf("testInsanity()\n")
+	r = make(map[UserId]map[Numberz]*Insanity)
+	r[1] = map[Numberz]*Insanity {
+		2: argument,
+		3: argument,
+	}
+	r[2] = map[Numberz]*Insanity {
+		6: NewInsanity(),
+	}
+	return
+}
+
+// Prints 'testMulti()'
+// @param byte arg0 -
+// @param i32 arg1 -
+// @param i64 arg2 -
+// @param map<i16, string> arg3 -
+// @param Numberz arg4 -
+// @param UserId arg5 -
+// @return Xtruct - returns an Xtruct with StringThing = "Hello2, ByteThing = arg0, I32Thing = arg1
+//    and I64Thing = arg2
+//
+// Parameters:
+//  - Arg0
+//  - Arg1
+//  - Arg2
+//  - Arg3
+//  - Arg4
+//  - Arg5
+func (p *printingHandler) TestMulti(ctx context.Context, arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 Numberz, arg5 UserId) (r *Xtruct, err error) {
+	fmt.Printf("testMulti()\n")
+	r = NewXtruct()
+
+	r.StringThing = "Hello2"
+	r.ByteThing = arg0
+	r.I32Thing = arg1
+	r.I64Thing = arg2
+	return
+}
+
+// Print 'testException(%s)' with arg as '%s'
+// @param string arg - a string indication what type of exception to throw
+// if arg == "Xception" throw Xception with errorCode = 1001 and message = arg
+// elsen if arg == "TException" throw TException
+// else do not throw anything
+//
+// Parameters:
+//  - Arg
+func (p *printingHandler) TestException(ctx context.Context, arg string) (err error) {
+	fmt.Printf("testException(%s)\n", arg)
+	switch arg {
+	case "Xception":
+		e := NewXception()
+		e.ErrorCode = 1001
+		e.Message = arg
+		return e
+	case "TException":
+		return errors.New("Just TException")
+	}
+	return
+}
+
+// Print 'testMultiException(%s, %s)' with arg0 as '%s' and arg1 as '%s'
+// @param string arg - a string indication what type of exception to throw
+// if arg0 == "Xception" throw Xception with errorCode = 1001 and message = "This is an Xception"
+// elsen if arg0 == "Xception2" throw Xception2 with errorCode = 2002 and message = "This is an Xception2"
+// else do not throw anything
+// @return Xtruct - an Xtruct with StringThing = arg1
+//
+// Parameters:
+//  - Arg0
+//  - Arg1
+func (p *printingHandler) TestMultiException(ctx context.Context, arg0 string, arg1 string) (r *Xtruct, err error) {
+	fmt.Printf("testMultiException(%s, %s)\n", arg0, arg1)
+	switch arg0 {
+
+	case "Xception":
+		e := NewXception()
+		e.ErrorCode = 1001
+		e.Message = "This is an Xception"
+		return nil, e
+	case "Xception2":
+		e := NewXception2()
+		e.ErrorCode = 2002
+		e.StructThing = NewXtruct()
+		e.StructThing.StringThing = "This is an Xception2"
+		return nil, e
+	default:
+		r = NewXtruct()
+		r.StringThing = arg1
+		return
+	}
+}
+
+// Print 'testOneway(%d): Sleeping...' with secondsToSleep as '%d'
+// sleep 'secondsToSleep'
+// Print 'testOneway(%d): done sleeping!' with secondsToSleep as '%d'
+// @param i32 secondsToSleep - the number of seconds to sleep
+//
+// Parameters:
+//  - SecondsToSleep
+func (p *printingHandler) TestOneway(ctx context.Context, secondsToSleep int32) (err error) {
+	fmt.Printf("testOneway(%d): Sleeping...\n", secondsToSleep)
+	time.Sleep(time.Second * time.Duration(secondsToSleep))
+	fmt.Printf("testOneway(%d): done sleeping!\n", secondsToSleep)
+	return
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/tutorial/go/Makefile.am
----------------------------------------------------------------------
diff --git a/tutorial/go/Makefile.am b/tutorial/go/Makefile.am
index a707d5d..c328d38 100644
--- a/tutorial/go/Makefile.am
+++ b/tutorial/go/Makefile.am
@@ -20,27 +20,30 @@
 THRIFT = $(top_builddir)/compiler/cpp/thrift
 
 gen-go/tutorial/calculator.go gen-go/shared/shared_service.go: $(top_srcdir)/tutorial/tutorial.thrift
-	$(THRIFT) --gen go -r $<
+	$(THRIFT) --gen go:legacy_context -r $<
 
 all-local: gen-go/tutorial/calculator.go
 
-
-check: src/git.apache.org/thrift.git/lib/go/thrift
-	$(THRIFT) -r --gen go $(top_srcdir)/tutorial/tutorial.thrift
+check: src/git.apache.org/thrift.git/lib/go/thrift thirdparty-dep
+	$(THRIFT) -r --gen go:legacy_context $(top_srcdir)/tutorial/tutorial.thrift
 	cp -r gen-go/* src/
-	GOPATH=`pwd` $(GO) build ./...
-	GOPATH=`pwd` $(GO) build -o go-tutorial src/*.go
+	GOPATH=`pwd` $(GO) build -o go-tutorial ./src
 	GOPATH=`pwd` $(GO) build -o calculator-remote src/tutorial/calculator-remote/calculator-remote.go
 
 src/git.apache.org/thrift.git/lib/go/thrift:
 	mkdir -p src/git.apache.org/thrift.git/lib/go
 	ln -sf $(realpath $(top_srcdir)/lib/go/thrift) src/git.apache.org/thrift.git/lib/go/thrift
 
+thirdparty-dep:
+	mkdir -p src/golang.org/x/net
+	GOPATH=`pwd`/gopath $(GO) get golang.org/x/net/context
+	ln -sf `pwd`/gopath/src/golang.org/x/net/context src/golang.org/x/net/context
+
 tutorialserver: all
 	GOPATH=`pwd` $(GO) run src/*.go -server=true
 
 tutorialclient: all
-	GOPATH=`pwd` $(GO) run src/*.go 
+	GOPATH=`pwd` $(GO) run src/*.go
 
 tutorialsecureserver: all
 	GOPATH=`pwd` $(GO) run src/*.go -server=true -secure=true

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/tutorial/go/src/handler.go
----------------------------------------------------------------------
diff --git a/tutorial/go/src/handler.go b/tutorial/go/src/handler.go
index 1763832..783b432 100644
--- a/tutorial/go/src/handler.go
+++ b/tutorial/go/src/handler.go
@@ -1,3 +1,5 @@
+// +build !go1.7
+
 package main
 
 /*
@@ -24,6 +26,8 @@ import (
 	"shared"
 	"strconv"
 	"tutorial"
+
+	"golang.org/x/net/context"
 )
 
 type CalculatorHandler struct {
@@ -34,17 +38,17 @@ func NewCalculatorHandler() *CalculatorHandler {
 	return &CalculatorHandler{log: make(map[int]*shared.SharedStruct)}
 }
 
-func (p *CalculatorHandler) Ping() (err error) {
+func (p *CalculatorHandler) Ping(ctx context.Context) (err error) {
 	fmt.Print("ping()\n")
 	return nil
 }
 
-func (p *CalculatorHandler) Add(num1 int32, num2 int32) (retval17 int32, err error) {
+func (p *CalculatorHandler) Add(ctx context.Context, num1 int32, num2 int32) (retval17 int32, err error) {
 	fmt.Print("add(", num1, ",", num2, ")\n")
 	return num1 + num2, nil
 }
 
-func (p *CalculatorHandler) Calculate(logid int32, w *tutorial.Work) (val int32, err error) {
+func (p *CalculatorHandler) Calculate(ctx context.Context, logid int32, w *tutorial.Work) (val int32, err error) {
 	fmt.Print("calculate(", logid, ", {", w.Op, ",", w.Num1, ",", w.Num2, "})\n")
 	switch w.Op {
 	case tutorial.Operation_ADD:
@@ -89,13 +93,13 @@ func (p *CalculatorHandler) Calculate(logid int32, w *tutorial.Work) (val int32,
 	return val, err
 }
 
-func (p *CalculatorHandler) GetStruct(key int32) (*shared.SharedStruct, error) {
+func (p *CalculatorHandler) GetStruct(ctx context.Context, key int32) (*shared.SharedStruct, error) {
 	fmt.Print("getStruct(", key, ")\n")
 	v, _ := p.log[int(key)]
 	return v, nil
 }
 
-func (p *CalculatorHandler) Zip() (err error) {
+func (p *CalculatorHandler) Zip(ctx context.Context) (err error) {
 	fmt.Print("zip()\n")
 	return nil
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/tutorial/go/src/handler_go17.go
----------------------------------------------------------------------
diff --git a/tutorial/go/src/handler_go17.go b/tutorial/go/src/handler_go17.go
new file mode 100644
index 0000000..d6752cc
--- /dev/null
+++ b/tutorial/go/src/handler_go17.go
@@ -0,0 +1,104 @@
+// +build go1.7
+
+package main
+
+/*
+ * 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.
+ */
+
+import (
+	"context"
+	"fmt"
+	"shared"
+	"strconv"
+	"tutorial"
+)
+
+type CalculatorHandler struct {
+	log map[int]*shared.SharedStruct
+}
+
+func NewCalculatorHandler() *CalculatorHandler {
+	return &CalculatorHandler{log: make(map[int]*shared.SharedStruct)}
+}
+
+func (p *CalculatorHandler) Ping(ctx context.Context) (err error) {
+	fmt.Print("ping()\n")
+	return nil
+}
+
+func (p *CalculatorHandler) Add(ctx context.Context, num1 int32, num2 int32) (retval17 int32, err error) {
+	fmt.Print("add(", num1, ",", num2, ")\n")
+	return num1 + num2, nil
+}
+
+func (p *CalculatorHandler) Calculate(ctx context.Context, logid int32, w *tutorial.Work) (val int32, err error) {
+	fmt.Print("calculate(", logid, ", {", w.Op, ",", w.Num1, ",", w.Num2, "})\n")
+	switch w.Op {
+	case tutorial.Operation_ADD:
+		val = w.Num1 + w.Num2
+		break
+	case tutorial.Operation_SUBTRACT:
+		val = w.Num1 - w.Num2
+		break
+	case tutorial.Operation_MULTIPLY:
+		val = w.Num1 * w.Num2
+		break
+	case tutorial.Operation_DIVIDE:
+		if w.Num2 == 0 {
+			ouch := tutorial.NewInvalidOperation()
+			ouch.WhatOp = int32(w.Op)
+			ouch.Why = "Cannot divide by 0"
+			err = ouch
+			return
+		}
+		val = w.Num1 / w.Num2
+		break
+	default:
+		ouch := tutorial.NewInvalidOperation()
+		ouch.WhatOp = int32(w.Op)
+		ouch.Why = "Unknown operation"
+		err = ouch
+		return
+	}
+	entry := shared.NewSharedStruct()
+	entry.Key = logid
+	entry.Value = strconv.Itoa(int(val))
+	k := int(logid)
+	/*
+	   oldvalue, exists := p.log[k]
+	   if exists {
+	     fmt.Print("Replacing ", oldvalue, " with ", entry, " for key ", k, "\n")
+	   } else {
+	     fmt.Print("Adding ", entry, " for key ", k, "\n")
+	   }
+	*/
+	p.log[k] = entry
+	return val, err
+}
+
+func (p *CalculatorHandler) GetStruct(ctx context.Context, key int32) (*shared.SharedStruct, error) {
+	fmt.Print("getStruct(", key, ")\n")
+	v, _ := p.log[int(key)]
+	return v, nil
+}
+
+func (p *CalculatorHandler) Zip(ctx context.Context) (err error) {
+	fmt.Print("zip()\n")
+	return nil
+}


[2/2] thrift git commit: THRIFT-4236 Support context in go generated code Client: Go Patch: taozle

Posted by je...@apache.org.
THRIFT-4236 Support context in go generated code
Client: Go
Patch: taozle <zh...@gmail.com>

This closes #1309


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/c0d384a3
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/c0d384a3
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/c0d384a3

Branch: refs/heads/master
Commit: c0d384a38c2b43ee47cef86b1cd054e3f84dc909
Parents: 0dd8235
Author: taozle <zh...@gmail.com>
Authored: Mon Jul 17 18:40:42 2017 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Sat Jul 22 19:42:48 2017 +0200

----------------------------------------------------------------------
 Dockerfile                                      |   2 +-
 build/docker/centos/Dockerfile                  |   2 +-
 build/docker/debian/Dockerfile                  |   2 +-
 build/docker/ubuntu/Dockerfile                  |   2 +-
 .../cpp/src/thrift/generate/t_go_generator.cc   |  71 ++--
 configure.ac                                    |   2 +-
 doc/install/README.md                           |   2 +-
 lib/go/Makefile.am                              |   6 +-
 lib/go/test/Makefile.am                         |   3 +-
 lib/go/test/tests/go17.go                       |  47 +++
 lib/go/test/tests/multiplexed_protocol_test.go  |  11 -
 lib/go/test/tests/one_way_test.go               |   7 -
 lib/go/test/tests/pre_go17.go                   |  48 +++
 lib/go/test/tests/struct_args_rets_test.go      |   2 +-
 lib/go/test/tests/thrifttest_driver.go          |   4 +-
 lib/go/test/tests/thrifttest_handler.go         |  52 +--
 lib/go/test/tests/thrifttest_handler_go17.go    | 212 ++++++++++
 lib/go/thrift/common_test_go17.go               |  32 ++
 lib/go/thrift/common_test_pre_go17.go           |  32 ++
 lib/go/thrift/go17.go                           |  26 ++
 lib/go/thrift/http_transport.go                 |  25 --
 lib/go/thrift/http_transport_go17.go            |  38 ++
 lib/go/thrift/http_transport_pre_go17.go        |  40 ++
 lib/go/thrift/multiplexed_processor.go          | 104 -----
 lib/go/thrift/multiplexed_protocol.go           |  58 ++-
 lib/go/thrift/multiplexed_protocol_go17.go      |  53 +++
 lib/go/thrift/multiplexed_protocol_pre_go17.go  |  54 +++
 lib/go/thrift/pre_go17.go                       |  26 ++
 lib/go/thrift/processor.go                      |  15 +-
 lib/go/thrift/processor_factory2.go             |  59 ---
 lib/go/thrift/processor_go17.go                 |  34 ++
 lib/go/thrift/server.go                         |  16 -
 lib/go/thrift/simple_server.go                  |   2 +-
 lib/go/thrift/simple_server2.go                 | 180 ---------
 lib/go/thrift/simple_server_test.go             |   8 -
 test/go/Makefile.am                             |   3 +-
 test/go/src/bin/stress/go17.go                  |  62 +++
 test/go/src/bin/stress/main.go                  |  35 --
 test/go/src/bin/stress/pre_go17.go              |  63 +++
 test/go/src/common/clientserver_test.go         |  48 +--
 test/go/src/common/mock_handler.go              | 246 +++++++-----
 test/go/src/common/printing_handler.go          |  48 +--
 test/go/src/common/printing_handler_go17.go     | 386 +++++++++++++++++++
 tutorial/go/Makefile.am                         |  17 +-
 tutorial/go/src/handler.go                      |  14 +-
 tutorial/go/src/handler_go17.go                 | 104 +++++
 46 files changed, 1570 insertions(+), 733 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/Dockerfile
----------------------------------------------------------------------
diff --git a/Dockerfile b/Dockerfile
index 2413b91..0d7ad21 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -50,7 +50,7 @@ RUN buildDeps=" \
        /thrift \
     && cmake --build . --config Release \
     && make install \
-    && curl -k -sSL "https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz" -o /tmp/go.tar.gz \
+    && curl -k -sSL "https://storage.googleapis.com/golang/go1.5.2.linux-amd64.tar.gz" -o /tmp/go.tar.gz \
     && tar xzf /tmp/go.tar.gz -C /tmp \
     && cp /tmp/go/bin/gofmt /usr/bin/gofmt \
     && apt-get purge -y --auto-remove $buildDeps \

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/build/docker/centos/Dockerfile
----------------------------------------------------------------------
diff --git a/build/docker/centos/Dockerfile b/build/docker/centos/Dockerfile
index 974823b..1881343 100644
--- a/build/docker/centos/Dockerfile
+++ b/build/docker/centos/Dockerfile
@@ -102,7 +102,7 @@ RUN curl -sSL http://packages.erlang-solutions.com/rpm/centos/erlang_solutions.r
       erlang-tools
 
 # Go Dependencies
-RUN curl -sSL https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz
+RUN curl -sSL https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz
 ENV PATH /usr/local/go/bin:$PATH
 
 # Haskell Dependencies

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/build/docker/debian/Dockerfile
----------------------------------------------------------------------
diff --git a/build/docker/debian/Dockerfile b/build/docker/debian/Dockerfile
index 8aa0902..7bc74fc 100644
--- a/build/docker/debian/Dockerfile
+++ b/build/docker/debian/Dockerfile
@@ -155,7 +155,7 @@ RUN pip2 install -U ipaddress backports.ssl_match_hostname tornado
 RUN pip3 install -U backports.ssl_match_hostname tornado
 
 # Go
-RUN curl -sSL https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz
+RUN curl -sSL https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz
 ENV PATH /usr/local/go/bin:$PATH
 
 # Haxe

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/build/docker/ubuntu/Dockerfile
----------------------------------------------------------------------
diff --git a/build/docker/ubuntu/Dockerfile b/build/docker/ubuntu/Dockerfile
index 25089eb..a1ff5a1 100644
--- a/build/docker/ubuntu/Dockerfile
+++ b/build/docker/ubuntu/Dockerfile
@@ -177,7 +177,7 @@ RUN pip2 install -U ipaddress backports.ssl_match_hostname tornado
 RUN pip3 install -U backports.ssl_match_hostname tornado
 
 # Go
-RUN curl -sSL https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz
+RUN curl -sSL https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz | tar -C /usr/local/ -xz
 ENV PATH /usr/local/go/bin:$PATH
 
 # Haxe

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/compiler/cpp/src/thrift/generate/t_go_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/thrift/generate/t_go_generator.cc b/compiler/cpp/src/thrift/generate/t_go_generator.cc
index 499d8c1..a82ce72 100644
--- a/compiler/cpp/src/thrift/generate/t_go_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_go_generator.cc
@@ -81,7 +81,7 @@ public:
     gen_package_prefix_ = "";
     package_flag = "";
     read_write_private_ = false;
-    use_context_ = false;
+    legacy_context_ = false;
     ignore_initialisms_ = false;
     for( iter = parsed_options.begin(); iter != parsed_options.end(); ++iter) {
       if( iter->first.compare("package_prefix") == 0) {
@@ -92,8 +92,8 @@ public:
         package_flag = (iter->second);
       } else if( iter->first.compare("read_write_private") == 0) {
         read_write_private_ = true;
-      } else if( iter->first.compare("use_context") == 0) {
-        use_context_ = true;
+      } else if( iter->first.compare("legacy_context") == 0) {
+        legacy_context_ = true;
       } else if( iter->first.compare("ignore_initialisms") == 0) {
         ignore_initialisms_ =  true;
       } else {
@@ -288,7 +288,7 @@ private:
   std::string gen_package_prefix_;
   std::string gen_thrift_import_;
   bool read_write_private_;
-  bool use_context_;
+  bool legacy_context_;
   bool ignore_initialisms_;
 
   /**
@@ -884,7 +884,10 @@ string t_go_generator::go_imports_begin(bool consts) {
       "\t\"database/sql/driver\"\n"
       "\t\"errors\"\n";
   }
-  if (use_context_) {
+  if (legacy_context_) {
+    extra +=
+      "\t\"golang.org/x/net/context\"\n";
+  } else {
     extra +=
       "\t\"context\"\n";
   }
@@ -904,20 +907,13 @@ string t_go_generator::go_imports_begin(bool consts) {
  * This will have to do in lieu of more intelligent import statement construction
  */
 string t_go_generator::go_imports_end() {
-  string extra;
-
-  if (use_context_) {
-    extra +=
-      "var _ = context.Background\n";
-  }
-
   return string(
       ")\n\n"
       "// (needed to ensure safety because of naive import list construction.)\n"
       "var _ = thrift.ZERO\n"
       "var _ = fmt.Printf\n"
+      "var _ = context.Background\n"
       "var _ = reflect.DeepEqual\n"
-      + extra +
       "var _ = bytes.Equal\n\n");
 }
 
@@ -1842,7 +1838,7 @@ void t_go_generator::generate_service_interface(t_service* tservice) {
 
     for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
       generate_go_docstring(f_types_, (*f_iter));
-      f_types_ << indent() << function_signature_if(*f_iter, "", true, use_context_) << endl;
+      f_types_ << indent() << function_signature_if(*f_iter, "", true, true) << endl;
     }
   }
 
@@ -2604,36 +2600,31 @@ void t_go_generator::generate_service_server(t_service* tservice) {
   // Generate the header portion
   string self(tmp("self"));
 
-  string processorFunction("thrift.TProcessorFunction");
-  if (use_context_) {
-    processorFunction = "thrift.TProcessorFunction2";
-  }
-
   if (extends_processor.empty()) {
     f_types_ << indent() << "type " << serviceName << "Processor struct {" << endl;
-    f_types_ << indent() << "  processorMap map[string]" << processorFunction << endl;
+    f_types_ << indent() << "  processorMap map[string]thrift.TProcessorFunction" << endl;
     f_types_ << indent() << "  handler " << serviceName << endl;
     f_types_ << indent() << "}" << endl << endl;
     f_types_ << indent() << "func (p *" << serviceName
-               << "Processor) AddToProcessorMap(key string, processor " << processorFunction << ") {"
+               << "Processor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {"
                << endl;
     f_types_ << indent() << "  p.processorMap[key] = processor" << endl;
     f_types_ << indent() << "}" << endl << endl;
     f_types_ << indent() << "func (p *" << serviceName
                << "Processor) GetProcessorFunction(key string) "
-                  "(processor "<< processorFunction << ", ok bool) {" << endl;
+                  "(processor thrift.TProcessorFunction, ok bool) {" << endl;
     f_types_ << indent() << "  processor, ok = p.processorMap[key]" << endl;
     f_types_ << indent() << "  return processor, ok" << endl;
     f_types_ << indent() << "}" << endl << endl;
     f_types_ << indent() << "func (p *" << serviceName
-               << "Processor) ProcessorMap() map[string]" << processorFunction << "{" << endl;
+               << "Processor) ProcessorMap() map[string]thrift.TProcessorFunction {" << endl;
     f_types_ << indent() << "  return p.processorMap" << endl;
     f_types_ << indent() << "}" << endl << endl;
     f_types_ << indent() << "func New" << serviceName << "Processor(handler " << serviceName
                << ") *" << serviceName << "Processor {" << endl << endl;
     f_types_
         << indent() << "  " << self << " := &" << serviceName
-        << "Processor{handler:handler, processorMap:make(map[string]" << processorFunction << ")}"
+        << "Processor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)}"
         << endl;
 
     for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {
@@ -2643,24 +2634,16 @@ void t_go_generator::generate_service_server(t_service* tservice) {
                  << "{handler:handler}" << endl;
     }
 
-    string ctxParam("");
-    string ctxVar("");
-    if (use_context_) {
-        ctxParam = "ctx context.Context, ";
-        ctxVar = "ctx, ";
-    }
-
     string x(tmp("x"));
     f_types_ << indent() << "return " << self << endl;
     f_types_ << indent() << "}" << endl << endl;
     f_types_ << indent() << "func (p *" << serviceName
-               << "Processor) Process(" << ctxParam
-               << "iprot, oprot thrift.TProtocol) (success bool, err "
+               << "Processor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err "
                   "thrift.TException) {" << endl;
     f_types_ << indent() << "  name, _, seqId, err := iprot.ReadMessageBegin()" << endl;
     f_types_ << indent() << "  if err != nil { return false, err }" << endl;
     f_types_ << indent() << "  if processor, ok := p.GetProcessorFunction(name); ok {" << endl;
-    f_types_ << indent() << "    return processor.Process(" << ctxVar << "seqId, iprot, oprot)" << endl;
+    f_types_ << indent() << "    return processor.Process(ctx, seqId, iprot, oprot)" << endl;
     f_types_ << indent() << "  }" << endl;
     f_types_ << indent() << "  iprot.Skip(thrift.STRUCT)" << endl;
     f_types_ << indent() << "  iprot.ReadMessageEnd()" << endl;
@@ -2714,12 +2697,6 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function*
   string argsname = publicize(tfunction->get_name() + "_args", true);
   string resultname = publicize(tfunction->get_name() + "_result", true);
 
-  string ctxParam("");
-  string ctxVar("");
-  if (use_context_) {
-      ctxParam = "ctx context.Context, ";
-      ctxVar = "ctx";
-  }
   // t_struct* xs = tfunction->get_xceptions();
   // const std::vector<t_field*>& xceptions = xs->get_members();
   vector<t_field*>::const_iterator x_iter;
@@ -2727,7 +2704,7 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function*
   f_types_ << indent() << "  handler " << publicize(tservice->get_name()) << endl;
   f_types_ << indent() << "}" << endl << endl;
   f_types_ << indent() << "func (p *" << processorName
-             << ") Process(" << ctxParam << "seqId int32, iprot, oprot thrift.TProtocol) (success bool, err "
+             << ") Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err "
                 "thrift.TException) {" << endl;
   indent_up();
   f_types_ << indent() << "args := " << argsname << "{}" << endl;
@@ -2771,13 +2748,11 @@ void t_go_generator::generate_process_function(t_service* tservice, t_function*
   f_types_ << "err2 = p.handler." << publicize(tfunction->get_name()) << "(";
   bool first = true;
 
-  f_types_ << ctxVar;
+  f_types_ << "ctx";
   for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) {
     if (first) {
       first = false;
-      if (use_context_) {
-        f_types_ << ", ";
-      }
+      f_types_ << ", ";
     } else {
       f_types_ << ", ";
     }
@@ -3459,7 +3434,7 @@ string t_go_generator::function_signature(t_function* tfunction, string prefix)
  * Renders an interface function signature of the form 'type name(args)'
  *
  * @param tfunction Function definition
- * @param disableContext Client doesn't suppport context for now.
+ * @param enableContext Client doesn't suppport context for now.
  * @return String of rendered function definition
  */
 string t_go_generator::function_signature_if(t_function* tfunction, string prefix, bool addError, bool enableContext) {
@@ -3745,5 +3720,5 @@ THRIFT_REGISTER_GENERATOR(go, "Go",
                           "                     Disable automatic spelling correction of initialisms (e.g. \"URL\")\n" \
                           "    read_write_private\n"
                           "                     Make read/write methods private, default is public Read/Write\n" \
-                          "    use_context\n"
-                          "                     Make service method receive a context as first argument.\n")
+                          "    legacy_context\n"
+                          "                     Use legacy x/net/context instead of context in go<1.7.\n")

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/configure.ac
----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index fcb9c6d..0c628da 100755
--- a/configure.ac
+++ b/configure.ac
@@ -397,7 +397,7 @@ if test "$with_go" = "yes";  then
   AC_PATH_PROG([GO], [go])
   if [[ -x "$GO" ]] ; then
     AS_IF([test -n "$GO"],[
-      ax_go_version="1.7"
+      ax_go_version="1.4"
 
       AC_MSG_CHECKING([for Go version])
       golang_version=`$GO version 2>&1 | $SED -e 's/\(go \)\(version \)\(go\)\(@<:@0-9@:>@.@<:@0-9@:>@.@<:@0-9@:>@\)\(@<:@\*@:>@*\).*/\4/'`

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/doc/install/README.md
----------------------------------------------------------------------
diff --git a/doc/install/README.md b/doc/install/README.md
index 9e42115..e37f4ff 100644
--- a/doc/install/README.md
+++ b/doc/install/README.md
@@ -39,5 +39,5 @@ These are only required if you choose to build the libraries for the given langu
     * Bit::Vector
     * Class::Accessor
 * Haxe 3.1.3
-* Go 1.7
+* Go 1.4
 * Delphi 2010

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/go/Makefile.am b/lib/go/Makefile.am
index b26a890..f1bd0e6 100644
--- a/lib/go/Makefile.am
+++ b/lib/go/Makefile.am
@@ -31,10 +31,12 @@ install:
 	@echo '##############################################################'
 
 check-local:
-	$(GO) test -race ./thrift
+	GOPATH=`pwd` $(GO) get golang.org/x/net/context
+	GOPATH=`pwd` $(GO) test -race ./thrift
 
 all-local:
-	$(GO) build ./thrift
+	GOPATH=`pwd` $(GO) get golang.org/x/net/context
+	GOPATH=`pwd` $(GO) build ./thrift
 
 EXTRA_DIST = \
 	thrift \

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/test/Makefile.am
----------------------------------------------------------------------
diff --git a/lib/go/test/Makefile.am b/lib/go/test/Makefile.am
index bbcec96..35a5457 100644
--- a/lib/go/test/Makefile.am
+++ b/lib/go/test/Makefile.am
@@ -18,7 +18,7 @@
 #
 
 THRIFT = $(top_builddir)/compiler/cpp/thrift
-THRIFTARGS = -out gopath/src/ --gen go:thrift_import=thrift
+THRIFTARGS = -out gopath/src/ --gen go:thrift_import=thrift,legacy_context
 THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
 
 # Thrift for GO has problems with complex map keys: THRIFT-2063
@@ -57,6 +57,7 @@ gopath: $(THRIFT) $(THRIFTTEST) \
 	$(THRIFT) $(THRIFTARGS),read_write_private DontExportRWTest.thrift
 	$(THRIFT) $(THRIFTARGS),ignore_initialisms IgnoreInitialismsTest.thrift
 	GOPATH=`pwd`/gopath $(GO) get github.com/golang/mock/gomock
+	GOPATH=`pwd`/gopath $(GO) get golang.org/x/net/context
 	ln -nfs ../../../thrift gopath/src/thrift
 	ln -nfs ../../tests gopath/src/tests
 	cp -r ./dontexportrwtest gopath/src

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/test/tests/go17.go
----------------------------------------------------------------------
diff --git a/lib/go/test/tests/go17.go b/lib/go/test/tests/go17.go
new file mode 100644
index 0000000..dc3c9d5
--- /dev/null
+++ b/lib/go/test/tests/go17.go
@@ -0,0 +1,47 @@
+// +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 tests
+
+import (
+	"context"
+	"fmt"
+)
+
+var defaultCtx = context.Background()
+
+type FirstImpl struct{}
+
+func (f *FirstImpl) ReturnOne(ctx context.Context) (r int64, err error) {
+	return 1, nil
+}
+
+type SecondImpl struct{}
+
+func (s *SecondImpl) ReturnTwo(ctx context.Context) (r int64, err error) {
+	return 2, nil
+}
+
+type impl struct{}
+
+func (i *impl) Hi(ctx context.Context, in int64, s string) (err error)        { fmt.Println("Hi!"); return }
+func (i *impl) Emptyfunc(ctx context.Context) (err error)                     { return }
+func (i *impl) EchoInt(ctx context.Context, param int64) (r int64, err error) { return param, nil }

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/test/tests/multiplexed_protocol_test.go
----------------------------------------------------------------------
diff --git a/lib/go/test/tests/multiplexed_protocol_test.go b/lib/go/test/tests/multiplexed_protocol_test.go
index b1674bd..ccf7b30 100644
--- a/lib/go/test/tests/multiplexed_protocol_test.go
+++ b/lib/go/test/tests/multiplexed_protocol_test.go
@@ -36,17 +36,6 @@ func FindAvailableTCPServerPort() net.Addr {
 	}
 }
 
-type FirstImpl struct{}
-
-func (f *FirstImpl) ReturnOne() (r int64, err error) {
-	return 1, nil
-}
-
-type SecondImpl struct{}
-
-func (s *SecondImpl) ReturnTwo() (r int64, err error) {
-	return 2, nil
-}
 
 var processor = thrift.NewTMultiplexedProcessor()
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/test/tests/one_way_test.go
----------------------------------------------------------------------
diff --git a/lib/go/test/tests/one_way_test.go b/lib/go/test/tests/one_way_test.go
index 5bb1dae..d7519a2 100644
--- a/lib/go/test/tests/one_way_test.go
+++ b/lib/go/test/tests/one_way_test.go
@@ -20,7 +20,6 @@
 package tests
 
 import (
-	"fmt"
 	"net"
 	"onewaytest"
 	"testing"
@@ -37,12 +36,6 @@ func findPort() net.Addr {
 	}
 }
 
-type impl struct{}
-
-func (i *impl) Hi(in int64, s string) (err error)        { fmt.Println("Hi!"); return }
-func (i *impl) Emptyfunc() (err error)                   { return }
-func (i *impl) EchoInt(param int64) (r int64, err error) { return param, nil }
-
 const TIMEOUT = time.Second
 
 var addr net.Addr

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/test/tests/pre_go17.go
----------------------------------------------------------------------
diff --git a/lib/go/test/tests/pre_go17.go b/lib/go/test/tests/pre_go17.go
new file mode 100644
index 0000000..8ab4331
--- /dev/null
+++ b/lib/go/test/tests/pre_go17.go
@@ -0,0 +1,48 @@
+// +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 tests
+
+import (
+	"fmt"
+
+	"golang.org/x/net/context"
+)
+
+var defaultCtx = context.Background()
+
+type FirstImpl struct{}
+
+func (f *FirstImpl) ReturnOne(ctx context.Context) (r int64, err error) {
+	return 1, nil
+}
+
+type SecondImpl struct{}
+
+func (s *SecondImpl) ReturnTwo(ctx context.Context) (r int64, err error) {
+	return 2, nil
+}
+
+type impl struct{}
+
+func (i *impl) Hi(ctx context.Context, in int64, s string) (err error)        { fmt.Println("Hi!"); return }
+func (i *impl) Emptyfunc(ctx context.Context) (err error)                     { return }
+func (i *impl) EchoInt(ctx context.Context, param int64) (r int64, err error) { return param, nil }

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/test/tests/struct_args_rets_test.go
----------------------------------------------------------------------
diff --git a/lib/go/test/tests/struct_args_rets_test.go b/lib/go/test/tests/struct_args_rets_test.go
index 363423d..81e9b26 100644
--- a/lib/go/test/tests/struct_args_rets_test.go
+++ b/lib/go/test/tests/struct_args_rets_test.go
@@ -30,7 +30,7 @@ func staticCheckStructArgsResults() {
 	var iface st.AServ
 	var err error
 
-	sa, err = iface.StructAFunc_1structA(sa)
+	sa, err = iface.StructAFunc_1structA(defaultCtx, sa)
 	_ = err
 	_ = sa
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/test/tests/thrifttest_driver.go
----------------------------------------------------------------------
diff --git a/lib/go/test/tests/thrifttest_driver.go b/lib/go/test/tests/thrifttest_driver.go
index a1e6917..f8643ed 100644
--- a/lib/go/test/tests/thrifttest_driver.go
+++ b/lib/go/test/tests/thrifttest_driver.go
@@ -26,11 +26,11 @@ import (
 )
 
 type ThriftTestDriver struct {
-	client thrifttest.ThriftTest
+	client *thrifttest.ThriftTestClient
 	t      *testing.T
 }
 
-func NewThriftTestDriver(t *testing.T, client thrifttest.ThriftTest) *ThriftTestDriver {
+func NewThriftTestDriver(t *testing.T, client *thrifttest.ThriftTestClient) *ThriftTestDriver {
 	return &ThriftTestDriver{client, t}
 }
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/test/tests/thrifttest_handler.go
----------------------------------------------------------------------
diff --git a/lib/go/test/tests/thrifttest_handler.go b/lib/go/test/tests/thrifttest_handler.go
index 5b76066..6542fac 100644
--- a/lib/go/test/tests/thrifttest_handler.go
+++ b/lib/go/test/tests/thrifttest_handler.go
@@ -1,3 +1,5 @@
+// +build !go1.7
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
@@ -24,6 +26,8 @@ import (
 	"thrift"
 	"thrifttest"
 	"time"
+
+	"golang.org/x/net/context"
 )
 
 type SecondServiceHandler struct {
@@ -33,11 +37,11 @@ func NewSecondServiceHandler() *SecondServiceHandler {
 	return &SecondServiceHandler{}
 }
 
-func (p *SecondServiceHandler) BlahBlah() (err error) {
+func (p *SecondServiceHandler) BlahBlah(ctx context.Context) (err error) {
 	return nil
 }
 
-func (p *SecondServiceHandler) SecondtestString(thing string) (r string, err error) {
+func (p *SecondServiceHandler) SecondtestString(ctx context.Context, thing string) (r string, err error) {
 	return thing, nil
 }
 
@@ -48,71 +52,71 @@ func NewThriftTestHandler() *ThriftTestHandler {
 	return &ThriftTestHandler{}
 }
 
-func (p *ThriftTestHandler) TestVoid() (err error) {
+func (p *ThriftTestHandler) TestVoid(ctx context.Context) (err error) {
 	return nil
 }
 
-func (p *ThriftTestHandler) TestString(thing string) (r string, err error) {
+func (p *ThriftTestHandler) TestString(ctx context.Context, thing string) (r string, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestBool(thing bool) (r bool, err error) {
+func (p *ThriftTestHandler) TestBool(ctx context.Context, thing bool) (r bool, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestByte(thing int8) (r int8, err error) {
+func (p *ThriftTestHandler) TestByte(ctx context.Context, thing int8) (r int8, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestI32(thing int32) (r int32, err error) {
+func (p *ThriftTestHandler) TestI32(ctx context.Context, thing int32) (r int32, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestI64(thing int64) (r int64, err error) {
+func (p *ThriftTestHandler) TestI64(ctx context.Context, thing int64) (r int64, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestDouble(thing float64) (r float64, err error) {
+func (p *ThriftTestHandler) TestDouble(ctx context.Context, thing float64) (r float64, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestBinary(thing []byte) (r []byte, err error) {
+func (p *ThriftTestHandler) TestBinary(ctx context.Context, thing []byte) (r []byte, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestStruct(thing *thrifttest.Xtruct) (r *thrifttest.Xtruct, err error) {
+func (p *ThriftTestHandler) TestStruct(ctx context.Context, thing *thrifttest.Xtruct) (r *thrifttest.Xtruct, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestNest(thing *thrifttest.Xtruct2) (r *thrifttest.Xtruct2, err error) {
+func (p *ThriftTestHandler) TestNest(ctx context.Context, thing *thrifttest.Xtruct2) (r *thrifttest.Xtruct2, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestMap(thing map[int32]int32) (r map[int32]int32, err error) {
+func (p *ThriftTestHandler) TestMap(ctx context.Context, thing map[int32]int32) (r map[int32]int32, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestStringMap(thing map[string]string) (r map[string]string, err error) {
+func (p *ThriftTestHandler) TestStringMap(ctx context.Context, thing map[string]string) (r map[string]string, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestSet(thing []int32) (r []int32, err error) {
+func (p *ThriftTestHandler) TestSet(ctx context.Context, thing []int32) (r []int32, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestList(thing []int32) (r []int32, err error) {
+func (p *ThriftTestHandler) TestList(ctx context.Context, thing []int32) (r []int32, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestEnum(thing thrifttest.Numberz) (r thrifttest.Numberz, err error) {
+func (p *ThriftTestHandler) TestEnum(ctx context.Context, thing thrifttest.Numberz) (r thrifttest.Numberz, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestTypedef(thing thrifttest.UserId) (r thrifttest.UserId, err error) {
+func (p *ThriftTestHandler) TestTypedef(ctx context.Context, thing thrifttest.UserId) (r thrifttest.UserId, err error) {
 	return thing, nil
 }
 
-func (p *ThriftTestHandler) TestMapMap(hello int32) (r map[int32]map[int32]int32, err error) {
+func (p *ThriftTestHandler) TestMapMap(ctx context.Context, hello int32) (r map[int32]map[int32]int32, err error) {
 	r = make(map[int32]map[int32]int32)
 	pos := make(map[int32]int32)
 	neg := make(map[int32]int32)
@@ -127,7 +131,7 @@ func (p *ThriftTestHandler) TestMapMap(hello int32) (r map[int32]map[int32]int32
 	return r, nil
 }
 
-func (p *ThriftTestHandler) TestInsanity(argument *thrifttest.Insanity) (r map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity, err error) {
+func (p *ThriftTestHandler) TestInsanity(ctx context.Context, argument *thrifttest.Insanity) (r map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity, err error) {
 	hello := thrifttest.NewXtruct()
 	hello.StringThing = "Hello2"
 	hello.ByteThing = 2
@@ -162,7 +166,7 @@ func (p *ThriftTestHandler) TestInsanity(argument *thrifttest.Insanity) (r map[t
 	return insane, nil
 }
 
-func (p *ThriftTestHandler) TestMulti(arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 thrifttest.Numberz, arg5 thrifttest.UserId) (r *thrifttest.Xtruct, err error) {
+func (p *ThriftTestHandler) TestMulti(ctx context.Context, arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 thrifttest.Numberz, arg5 thrifttest.UserId) (r *thrifttest.Xtruct, err error) {
 	r = thrifttest.NewXtruct()
 	r.StringThing = "Hello2"
 	r.ByteThing = arg0
@@ -171,7 +175,7 @@ func (p *ThriftTestHandler) TestMulti(arg0 int8, arg1 int32, arg2 int64, arg3 ma
 	return r, nil
 }
 
-func (p *ThriftTestHandler) TestException(arg string) (err error) {
+func (p *ThriftTestHandler) TestException(ctx context.Context, arg string) (err error) {
 	if arg == "Xception" {
 		x := thrifttest.NewXception()
 		x.ErrorCode = 1001
@@ -184,7 +188,7 @@ func (p *ThriftTestHandler) TestException(arg string) (err error) {
 	}
 }
 
-func (p *ThriftTestHandler) TestMultiException(arg0 string, arg1 string) (r *thrifttest.Xtruct, err error) {
+func (p *ThriftTestHandler) TestMultiException(ctx context.Context, arg0 string, arg1 string) (r *thrifttest.Xtruct, err error) {
 	if arg0 == "Xception" {
 		x := thrifttest.NewXception()
 		x.ErrorCode = 1001
@@ -203,7 +207,7 @@ func (p *ThriftTestHandler) TestMultiException(arg0 string, arg1 string) (r *thr
 	return res, nil
 }
 
-func (p *ThriftTestHandler) TestOneway(secondsToSleep int32) (err error) {
+func (p *ThriftTestHandler) TestOneway(ctx context.Context, secondsToSleep int32) (err error) {
 	time.Sleep(time.Second * time.Duration(secondsToSleep))
 	return nil
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/test/tests/thrifttest_handler_go17.go
----------------------------------------------------------------------
diff --git a/lib/go/test/tests/thrifttest_handler_go17.go b/lib/go/test/tests/thrifttest_handler_go17.go
new file mode 100644
index 0000000..e022a3d
--- /dev/null
+++ b/lib/go/test/tests/thrifttest_handler_go17.go
@@ -0,0 +1,212 @@
+// +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 tests
+
+import (
+	"context"
+	"errors"
+	"thrift"
+	"thrifttest"
+	"time"
+)
+
+type SecondServiceHandler struct {
+}
+
+func NewSecondServiceHandler() *SecondServiceHandler {
+	return &SecondServiceHandler{}
+}
+
+func (p *SecondServiceHandler) BlahBlah(ctx context.Context) (err error) {
+	return nil
+}
+
+func (p *SecondServiceHandler) SecondtestString(ctx context.Context, thing string) (r string, err error) {
+	return thing, nil
+}
+
+type ThriftTestHandler struct {
+}
+
+func NewThriftTestHandler() *ThriftTestHandler {
+	return &ThriftTestHandler{}
+}
+
+func (p *ThriftTestHandler) TestVoid(ctx context.Context) (err error) {
+	return nil
+}
+
+func (p *ThriftTestHandler) TestString(ctx context.Context, thing string) (r string, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestBool(ctx context.Context, thing bool) (r bool, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestByte(ctx context.Context, thing int8) (r int8, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestI32(ctx context.Context, thing int32) (r int32, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestI64(ctx context.Context, thing int64) (r int64, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestDouble(ctx context.Context, thing float64) (r float64, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestBinary(ctx context.Context, thing []byte) (r []byte, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestStruct(ctx context.Context, thing *thrifttest.Xtruct) (r *thrifttest.Xtruct, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestNest(ctx context.Context, thing *thrifttest.Xtruct2) (r *thrifttest.Xtruct2, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestMap(ctx context.Context, thing map[int32]int32) (r map[int32]int32, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestStringMap(ctx context.Context, thing map[string]string) (r map[string]string, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestSet(ctx context.Context, thing []int32) (r []int32, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestList(ctx context.Context, thing []int32) (r []int32, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestEnum(ctx context.Context, thing thrifttest.Numberz) (r thrifttest.Numberz, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestTypedef(ctx context.Context, thing thrifttest.UserId) (r thrifttest.UserId, err error) {
+	return thing, nil
+}
+
+func (p *ThriftTestHandler) TestMapMap(ctx context.Context, hello int32) (r map[int32]map[int32]int32, err error) {
+	r = make(map[int32]map[int32]int32)
+	pos := make(map[int32]int32)
+	neg := make(map[int32]int32)
+
+	for i := int32(1); i < 5; i++ {
+		pos[i] = i
+		neg[-i] = -i
+	}
+	r[4] = pos
+	r[-4] = neg
+
+	return r, nil
+}
+
+func (p *ThriftTestHandler) TestInsanity(ctx context.Context, argument *thrifttest.Insanity) (r map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity, err error) {
+	hello := thrifttest.NewXtruct()
+	hello.StringThing = "Hello2"
+	hello.ByteThing = 2
+	hello.I32Thing = 2
+	hello.I64Thing = 2
+
+	goodbye := thrifttest.NewXtruct()
+	goodbye.StringThing = "Goodbye4"
+	goodbye.ByteThing = 4
+	goodbye.I32Thing = 4
+	goodbye.I64Thing = 4
+
+	crazy := thrifttest.NewInsanity()
+	crazy.UserMap = make(map[thrifttest.Numberz]thrifttest.UserId)
+	crazy.UserMap[thrifttest.Numberz_EIGHT] = 8
+	crazy.UserMap[thrifttest.Numberz_FIVE] = 5
+	crazy.Xtructs = []*thrifttest.Xtruct{goodbye, hello}
+
+	first_map := make(map[thrifttest.Numberz]*thrifttest.Insanity)
+	second_map := make(map[thrifttest.Numberz]*thrifttest.Insanity)
+
+	first_map[thrifttest.Numberz_TWO] = crazy
+	first_map[thrifttest.Numberz_THREE] = crazy
+
+	looney := thrifttest.NewInsanity()
+	second_map[thrifttest.Numberz_SIX] = looney
+
+	var insane = make(map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity)
+	insane[1] = first_map
+	insane[2] = second_map
+
+	return insane, nil
+}
+
+func (p *ThriftTestHandler) TestMulti(ctx context.Context, arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 thrifttest.Numberz, arg5 thrifttest.UserId) (r *thrifttest.Xtruct, err error) {
+	r = thrifttest.NewXtruct()
+	r.StringThing = "Hello2"
+	r.ByteThing = arg0
+	r.I32Thing = arg1
+	r.I64Thing = arg2
+	return r, nil
+}
+
+func (p *ThriftTestHandler) TestException(ctx context.Context, arg string) (err error) {
+	if arg == "Xception" {
+		x := thrifttest.NewXception()
+		x.ErrorCode = 1001
+		x.Message = arg
+		return x
+	} else if arg == "TException" {
+		return thrift.TException(errors.New(arg))
+	} else {
+		return nil
+	}
+}
+
+func (p *ThriftTestHandler) TestMultiException(ctx context.Context, arg0 string, arg1 string) (r *thrifttest.Xtruct, err error) {
+	if arg0 == "Xception" {
+		x := thrifttest.NewXception()
+		x.ErrorCode = 1001
+		x.Message = "This is an Xception"
+		return nil, x
+	} else if arg0 == "Xception2" {
+		x2 := thrifttest.NewXception2()
+		x2.ErrorCode = 2002
+		x2.StructThing = thrifttest.NewXtruct()
+		x2.StructThing.StringThing = "This is an Xception2"
+		return nil, x2
+	}
+
+	res := thrifttest.NewXtruct()
+	res.StringThing = arg1
+	return res, nil
+}
+
+func (p *ThriftTestHandler) TestOneway(ctx context.Context, secondsToSleep int32) (err error) {
+	time.Sleep(time.Second * time.Duration(secondsToSleep))
+	return nil
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/common_test_go17.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/common_test_go17.go b/lib/go/thrift/common_test_go17.go
new file mode 100644
index 0000000..2c729a2
--- /dev/null
+++ b/lib/go/thrift/common_test_go17.go
@@ -0,0 +1,32 @@
+// +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 thrift
+
+import "context"
+
+type mockProcessor struct {
+	ProcessFunc func(in, out TProtocol) (bool, TException)
+}
+
+func (m *mockProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) {
+	return m.ProcessFunc(in, out)
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/common_test_pre_go17.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/common_test_pre_go17.go b/lib/go/thrift/common_test_pre_go17.go
new file mode 100644
index 0000000..e6d0c4d
--- /dev/null
+++ b/lib/go/thrift/common_test_pre_go17.go
@@ -0,0 +1,32 @@
+// +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 thrift
+
+import "golang.org/x/net/context"
+
+type mockProcessor struct {
+	ProcessFunc func(in, out TProtocol) (bool, TException)
+}
+
+func (m *mockProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) {
+	return m.ProcessFunc(in, out)
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/go17.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/go17.go b/lib/go/thrift/go17.go
new file mode 100644
index 0000000..e3b21c4
--- /dev/null
+++ b/lib/go/thrift/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 thrift
+
+import "context"
+
+var defaultCtx = context.Background()

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/http_transport.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/http_transport.go b/lib/go/thrift/http_transport.go
index d5b5b7c..601855b 100644
--- a/lib/go/thrift/http_transport.go
+++ b/lib/go/thrift/http_transport.go
@@ -21,36 +21,11 @@ package thrift
 
 import (
 	"compress/gzip"
-	"context"
 	"io"
 	"net/http"
 	"strings"
 )
 
-// NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function
-func NewThriftHandlerFunc(processor TProcessor,
-	inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) {
-
-	return gz(func(w http.ResponseWriter, r *http.Request) {
-		w.Header().Add("Content-Type", "application/x-thrift")
-
-		transport := NewStreamTransport(r.Body, w)
-		processor.Process(inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport))
-	})
-}
-
-// NewThriftHandlerFunc2 is same as NewThriftHandlerFunc but requires a Context as its first param.
-func NewThriftHandlerFunc2(ctx context.Context, processor TProcessor2,
-	inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) {
-
-	return gz(func(w http.ResponseWriter, r *http.Request) {
-		w.Header().Add("Content-Type", "application/x-thrift")
-
-		transport := NewStreamTransport(r.Body, w)
-		processor.Process(ctx, inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport))
-	})
-}
-
 // gz transparently compresses the HTTP response if the client supports it.
 func gz(handler http.HandlerFunc) http.HandlerFunc {
 	return func(w http.ResponseWriter, r *http.Request) {

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/http_transport_go17.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/http_transport_go17.go b/lib/go/thrift/http_transport_go17.go
new file mode 100644
index 0000000..1313ac2
--- /dev/null
+++ b/lib/go/thrift/http_transport_go17.go
@@ -0,0 +1,38 @@
+// +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 thrift
+
+import (
+	"net/http"
+)
+
+// NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function
+func NewThriftHandlerFunc(processor TProcessor,
+	inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) {
+
+	return gz(func(w http.ResponseWriter, r *http.Request) {
+		w.Header().Add("Content-Type", "application/x-thrift")
+
+		transport := NewStreamTransport(r.Body, w)
+		processor.Process(r.Context(), inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport))
+	})
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/http_transport_pre_go17.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/http_transport_pre_go17.go b/lib/go/thrift/http_transport_pre_go17.go
new file mode 100644
index 0000000..13aa1c1
--- /dev/null
+++ b/lib/go/thrift/http_transport_pre_go17.go
@@ -0,0 +1,40 @@
+// +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 thrift
+
+import (
+	"net/http"
+
+	"golang.org/x/net/context"
+)
+
+// NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function
+func NewThriftHandlerFunc(processor TProcessor,
+	inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) {
+
+	return gz(func(w http.ResponseWriter, r *http.Request) {
+		w.Header().Add("Content-Type", "application/x-thrift")
+
+		transport := NewStreamTransport(r.Body, w)
+		processor.Process(context.Background(), inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport))
+	})
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/multiplexed_processor.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/multiplexed_processor.go b/lib/go/thrift/multiplexed_processor.go
deleted file mode 100644
index d205db8..0000000
--- a/lib/go/thrift/multiplexed_processor.go
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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 thrift
-
-import (
-	"context"
-	"fmt"
-	"strings"
-)
-
-/*
-TMultiplexedProcessor2 is a TProcessor allowing
-a single TServer to provide multiple services with
-context support in TProcessor.
-
-To do so, you instantiate the processor and then register additional
-processors with it, as shown in the following example:
-
-var processor = thrift.NewTMultiplexedProcessor2()
-
-firstProcessor :=
-processor.RegisterProcessor("FirstService", firstProcessor)
-
-processor.registerProcessor(
-  "Calculator",
-  Calculator.NewCalculatorProcessor(&CalculatorHandler{}),
-)
-
-processor.registerProcessor(
-  "WeatherReport",
-  WeatherReport.NewWeatherReportProcessor(&WeatherReportHandler{}),
-)
-
-serverTransport, err := thrift.NewTServerSocketTimeout(addr, TIMEOUT)
-if err != nil {
-  t.Fatal("Unable to create server socket", err)
-}
-server := thrift.NewTSimpleServer2(processor, serverTransport)
-server.Serve();
-*/
-
-type TMultiplexedProcessor2 struct {
-	serviceProcessorMap map[string]TProcessor2
-	DefaultProcessor    TProcessor2
-}
-
-func NewTMultiplexedProcessor2() *TMultiplexedProcessor2 {
-	return &TMultiplexedProcessor2{
-		serviceProcessorMap: make(map[string]TProcessor2),
-	}
-}
-
-func (t *TMultiplexedProcessor2) RegisterDefault(processor TProcessor2) {
-	t.DefaultProcessor = processor
-}
-
-func (t *TMultiplexedProcessor2) RegisterProcessor(name string, processor TProcessor2) {
-	if t.serviceProcessorMap == nil {
-		t.serviceProcessorMap = make(map[string]TProcessor2)
-	}
-	t.serviceProcessorMap[name] = processor
-}
-
-func (t *TMultiplexedProcessor2) Process(ctx context.Context, in, out TProtocol) (bool, TException) {
-	name, typeId, seqid, err := in.ReadMessageBegin()
-	if err != nil {
-		return false, err
-	}
-	if typeId != CALL && typeId != ONEWAY {
-		return false, fmt.Errorf("Unexpected message type %v", typeId)
-	}
-	//extract the service name
-	v := strings.SplitN(name, MULTIPLEXED_SEPARATOR, 2)
-	if len(v) != 2 {
-		if t.DefaultProcessor != nil {
-			smb := NewStoredMessageProtocol(in, name, typeId, seqid)
-			return t.DefaultProcessor.Process(ctx, smb, out)
-		}
-		return false, fmt.Errorf("Service name not found in message name: %s.  Did you forget to use a TMultiplexProtocol in your client?", name)
-	}
-	actualProcessor, ok := t.serviceProcessorMap[v[0]]
-	if !ok {
-		return false, fmt.Errorf("Service name not found: %s.  Did you forget to call registerProcessor()?", v[0])
-	}
-	smb := NewStoredMessageProtocol(in, v[1], typeId, seqid)
-	return actualProcessor.Process(ctx, smb, out)
-}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/multiplexed_protocol.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/multiplexed_protocol.go b/lib/go/thrift/multiplexed_protocol.go
index 6ae7be6..b7f4f8a 100644
--- a/lib/go/thrift/multiplexed_protocol.go
+++ b/lib/go/thrift/multiplexed_protocol.go
@@ -19,11 +19,6 @@
 
 package thrift
 
-import (
-	"fmt"
-	"strings"
-)
-
 /*
 TMultiplexedProtocol is a protocol-independent concrete decorator
 that allows a Thrift client to communicate with a multiplexing Thrift server,
@@ -76,11 +71,33 @@ func (t *TMultiplexedProtocol) WriteMessageBegin(name string, typeId TMessageTyp
 }
 
 /*
-This is the non-context version for TProcessor.
+TMultiplexedProcessor is a TProcessor allowing
+a single TServer to provide multiple services.
+
+To do so, you instantiate the processor and then register additional
+processors with it, as shown in the following example:
+
+var processor = thrift.NewTMultiplexedProcessor()
 
-See description at file: multiplexed_processor.go
+firstProcessor :=
+processor.RegisterProcessor("FirstService", firstProcessor)
+
+processor.registerProcessor(
+  "Calculator",
+  Calculator.NewCalculatorProcessor(&CalculatorHandler{}),
+)
+
+processor.registerProcessor(
+  "WeatherReport",
+  WeatherReport.NewWeatherReportProcessor(&WeatherReportHandler{}),
+)
 
-Deprecated: use TMultiplexedProcessor2 for strong server programming.
+serverTransport, err := thrift.NewTServerSocketTimeout(addr, TIMEOUT)
+if err != nil {
+  t.Fatal("Unable to create server socket", err)
+}
+server := thrift.NewTSimpleServer2(processor, serverTransport)
+server.Serve();
 */
 
 type TMultiplexedProcessor struct {
@@ -105,31 +122,6 @@ func (t *TMultiplexedProcessor) RegisterProcessor(name string, processor TProces
 	t.serviceProcessorMap[name] = processor
 }
 
-func (t *TMultiplexedProcessor) Process(in, out TProtocol) (bool, TException) {
-	name, typeId, seqid, err := in.ReadMessageBegin()
-	if err != nil {
-		return false, err
-	}
-	if typeId != CALL && typeId != ONEWAY {
-		return false, fmt.Errorf("Unexpected message type %v", typeId)
-	}
-	//extract the service name
-	v := strings.SplitN(name, MULTIPLEXED_SEPARATOR, 2)
-	if len(v) != 2 {
-		if t.DefaultProcessor != nil {
-			smb := NewStoredMessageProtocol(in, name, typeId, seqid)
-			return t.DefaultProcessor.Process(smb, out)
-		}
-		return false, fmt.Errorf("Service name not found in message name: %s.  Did you forget to use a TMultiplexProtocol in your client?", name)
-	}
-	actualProcessor, ok := t.serviceProcessorMap[v[0]]
-	if !ok {
-		return false, fmt.Errorf("Service name not found: %s.  Did you forget to call registerProcessor()?", v[0])
-	}
-	smb := NewStoredMessageProtocol(in, v[1], typeId, seqid)
-	return actualProcessor.Process(smb, out)
-}
-
 //Protocol that use stored message for ReadMessageBegin
 type storedMessageProtocol struct {
 	TProtocol

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/multiplexed_protocol_go17.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/multiplexed_protocol_go17.go b/lib/go/thrift/multiplexed_protocol_go17.go
new file mode 100644
index 0000000..c71035e
--- /dev/null
+++ b/lib/go/thrift/multiplexed_protocol_go17.go
@@ -0,0 +1,53 @@
+// +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 thrift
+
+import (
+	"context"
+	"fmt"
+	"strings"
+)
+
+func (t *TMultiplexedProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) {
+	name, typeId, seqid, err := in.ReadMessageBegin()
+	if err != nil {
+		return false, err
+	}
+	if typeId != CALL && typeId != ONEWAY {
+		return false, fmt.Errorf("Unexpected message type %v", typeId)
+	}
+	//extract the service name
+	v := strings.SplitN(name, MULTIPLEXED_SEPARATOR, 2)
+	if len(v) != 2 {
+		if t.DefaultProcessor != nil {
+			smb := NewStoredMessageProtocol(in, name, typeId, seqid)
+			return t.DefaultProcessor.Process(ctx, smb, out)
+		}
+		return false, fmt.Errorf("Service name not found in message name: %s.  Did you forget to use a TMultiplexProtocol in your client?", name)
+	}
+	actualProcessor, ok := t.serviceProcessorMap[v[0]]
+	if !ok {
+		return false, fmt.Errorf("Service name not found: %s.  Did you forget to call registerProcessor()?", v[0])
+	}
+	smb := NewStoredMessageProtocol(in, v[1], typeId, seqid)
+	return actualProcessor.Process(ctx, smb, out)
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/multiplexed_protocol_pre_go17.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/multiplexed_protocol_pre_go17.go b/lib/go/thrift/multiplexed_protocol_pre_go17.go
new file mode 100644
index 0000000..5c27b38
--- /dev/null
+++ b/lib/go/thrift/multiplexed_protocol_pre_go17.go
@@ -0,0 +1,54 @@
+// +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 thrift
+
+import (
+	"fmt"
+	"strings"
+
+	"golang.org/x/net/context"
+)
+
+func (t *TMultiplexedProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) {
+	name, typeId, seqid, err := in.ReadMessageBegin()
+	if err != nil {
+		return false, err
+	}
+	if typeId != CALL && typeId != ONEWAY {
+		return false, fmt.Errorf("Unexpected message type %v", typeId)
+	}
+	//extract the service name
+	v := strings.SplitN(name, MULTIPLEXED_SEPARATOR, 2)
+	if len(v) != 2 {
+		if t.DefaultProcessor != nil {
+			smb := NewStoredMessageProtocol(in, name, typeId, seqid)
+			return t.DefaultProcessor.Process(ctx, smb, out)
+		}
+		return false, fmt.Errorf("Service name not found in message name: %s.  Did you forget to use a TMultiplexProtocol in your client?", name)
+	}
+	actualProcessor, ok := t.serviceProcessorMap[v[0]]
+	if !ok {
+		return false, fmt.Errorf("Service name not found: %s.  Did you forget to call registerProcessor()?", v[0])
+	}
+	smb := NewStoredMessageProtocol(in, v[1], typeId, seqid)
+	return actualProcessor.Process(ctx, smb, out)
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/pre_go17.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/pre_go17.go b/lib/go/thrift/pre_go17.go
new file mode 100644
index 0000000..cb564b8
--- /dev/null
+++ b/lib/go/thrift/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 thrift
+
+import "golang.org/x/net/context"
+
+var defaultCtx = context.Background()

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/processor.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/processor.go b/lib/go/thrift/processor.go
index 7f8f365..566aaaf 100644
--- a/lib/go/thrift/processor.go
+++ b/lib/go/thrift/processor.go
@@ -1,3 +1,5 @@
+// +build !go1.7
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements. See the NOTICE file
@@ -19,23 +21,14 @@
 
 package thrift
 
-import "context"
+import "golang.org/x/net/context"
 
 // A processor is a generic object which operates upon an input stream and
 // writes to some output stream.
 type TProcessor interface {
-	Process(in, out TProtocol) (bool, TException)
-}
-
-type TProcessorFunction interface {
-	Process(seqId int32, in, out TProtocol) (bool, TException)
-}
-
-// TProcessor2 is TProcessor with ctx as its first argument.
-type TProcessor2 interface {
 	Process(ctx context.Context, in, out TProtocol) (bool, TException)
 }
 
-type TProcessorFunction2 interface {
+type TProcessorFunction interface {
 	Process(ctx context.Context, seqId int32, in, out TProtocol) (bool, TException)
 }

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/processor_factory2.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/processor_factory2.go b/lib/go/thrift/processor_factory2.go
deleted file mode 100644
index bd587ad..0000000
--- a/lib/go/thrift/processor_factory2.go
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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 thrift
-
-// The default processor2 factory just returns a singleton
-// instance.
-// The TProcessorFactory2 is a context version of the orignal.
-type TProcessorFactory2 interface {
-	GetProcessor(trans TTransport) TProcessor2
-}
-
-type tProcessorFactory2 struct {
-	processor TProcessor2
-}
-
-func NewTProcessorFactory2(p TProcessor2) TProcessorFactory2 {
-	return &tProcessorFactory2{processor: p}
-}
-
-func (p *tProcessorFactory2) GetProcessor(trans TTransport) TProcessor2 {
-	return p.processor
-}
-
-/**
- * The default processor factory2 just returns a singleton
- * instance.
- */
-type TProcessorFunctionFactory2 interface {
-	GetProcessorFunction(trans TTransport) TProcessorFunction2
-}
-
-type tProcessorFunctionFactory2 struct {
-	processor TProcessorFunction2
-}
-
-func NewTProcessorFunctionFactory2(p TProcessorFunction2) TProcessorFunctionFactory2 {
-	return &tProcessorFunctionFactory2{processor: p}
-}
-
-func (p *tProcessorFunctionFactory2) GetProcessorFunction(trans TTransport) TProcessorFunction2 {
-	return p.processor
-}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/processor_go17.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/processor_go17.go b/lib/go/thrift/processor_go17.go
new file mode 100644
index 0000000..fb0b165
--- /dev/null
+++ b/lib/go/thrift/processor_go17.go
@@ -0,0 +1,34 @@
+// +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 thrift
+
+import "context"
+
+// A processor is a generic object which operates upon an input stream and
+// writes to some output stream.
+type TProcessor interface {
+	Process(ctx context.Context, in, out TProtocol) (bool, TException)
+}
+
+type TProcessorFunction interface {
+	Process(ctx context.Context, seqId int32, in, out TProtocol) (bool, TException)
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/server.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/server.go b/lib/go/thrift/server.go
index 3e8a656..f813fa3 100644
--- a/lib/go/thrift/server.go
+++ b/lib/go/thrift/server.go
@@ -33,19 +33,3 @@ type TServer interface {
 	// all servers are required to be cleanly stoppable.
 	Stop() error
 }
-
-// Same as TServer but use TProcessorFactory2 as processor factory.
-type TServer2 interface {
-	ProcessorFactory() TProcessorFactory2
-	ServerTransport() TServerTransport
-	InputTransportFactory() TTransportFactory
-	OutputTransportFactory() TTransportFactory
-	InputProtocolFactory() TProtocolFactory
-	OutputProtocolFactory() TProtocolFactory
-
-	// Starts the server
-	Serve() error
-	// Stops the server. This is optional on a per-implementation basis. Not
-	// all servers are required to be cleanly stoppable.
-	Stop() error
-}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/simple_server.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/simple_server.go b/lib/go/thrift/simple_server.go
index 72541b6..37081bd 100644
--- a/lib/go/thrift/simple_server.go
+++ b/lib/go/thrift/simple_server.go
@@ -198,7 +198,7 @@ func (p *TSimpleServer) processRequests(client TTransport) error {
 			return nil
 		}
 
-		ok, err := processor.Process(inputProtocol, outputProtocol)
+		ok, err := processor.Process(defaultCtx, inputProtocol, outputProtocol)
 		if err, ok := err.(TTransportException); ok && err.TypeId() == END_OF_FILE {
 			return nil
 		} else if err != nil {

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/simple_server2.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/simple_server2.go b/lib/go/thrift/simple_server2.go
deleted file mode 100644
index 9e9961f..0000000
--- a/lib/go/thrift/simple_server2.go
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * 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 thrift
-
-import (
-	"context"
-	"log"
-	"runtime/debug"
-	"sync"
-)
-
-/*
- * This is only a simple sample same as TSimpleServer but add context
- * usage support.
- */
-type TSimpleServer2 struct {
-	quit chan struct{}
-
-	processorFactory       TProcessorFactory2
-	serverTransport        TServerTransport
-	inputTransportFactory  TTransportFactory
-	outputTransportFactory TTransportFactory
-	inputProtocolFactory   TProtocolFactory
-	outputProtocolFactory  TProtocolFactory
-	sync.WaitGroup
-}
-
-func NewTSimpleServerWithContext(processor TProcessor2, serverTransport TServerTransport) *TSimpleServer2 {
-	return NewTSimpleServerFactoryWithContext(NewTProcessorFactory2(processor), serverTransport)
-}
-
-func NewTSimpleServerFactoryWithContext(processorFactory TProcessorFactory2, serverTransport TServerTransport) *TSimpleServer2 {
-	return &TSimpleServer2{
-		quit:                   make(chan struct{}, 1),
-		processorFactory:       processorFactory,
-		serverTransport:        serverTransport,
-		inputTransportFactory:  NewTTransportFactory(),
-		outputTransportFactory: NewTTransportFactory(),
-		inputProtocolFactory:   NewTBinaryProtocolFactoryDefault(),
-		outputProtocolFactory:  NewTBinaryProtocolFactoryDefault(),
-	}
-}
-
-func (p *TSimpleServer2) ProcessorFactory() TProcessorFactory2 {
-	return p.processorFactory
-}
-
-func (p *TSimpleServer2) ServerTransport() TServerTransport {
-	return p.serverTransport
-}
-
-func (p *TSimpleServer2) InputTransportFactory() TTransportFactory {
-	return p.inputTransportFactory
-}
-
-func (p *TSimpleServer2) OutputTransportFactory() TTransportFactory {
-	return p.outputTransportFactory
-}
-
-func (p *TSimpleServer2) InputProtocolFactory() TProtocolFactory {
-	return p.inputProtocolFactory
-}
-
-func (p *TSimpleServer2) OutputProtocolFactory() TProtocolFactory {
-	return p.outputProtocolFactory
-}
-
-func (p *TSimpleServer2) Listen() error {
-	return p.serverTransport.Listen()
-}
-
-func (p *TSimpleServer2) AcceptLoop() error {
-	for {
-		client, err := p.serverTransport.Accept()
-		if err != nil {
-			select {
-			case <-p.quit:
-				return nil
-			default:
-			}
-			return err
-		}
-		if client != nil {
-			p.Add(1)
-			go func() {
-				if err := p.processRequests(client); err != nil {
-					log.Println("error processing request:", err)
-				}
-			}()
-		}
-	}
-}
-
-func (p *TSimpleServer2) Serve() error {
-	err := p.Listen()
-	if err != nil {
-		return err
-	}
-	p.AcceptLoop()
-	return nil
-}
-
-var once2 sync.Once
-
-func (p *TSimpleServer2) Stop() error {
-	q := func() {
-		close(p.quit)
-		p.serverTransport.Interrupt()
-		p.Wait()
-	}
-	once2.Do(q)
-	return nil
-}
-
-func (p *TSimpleServer2) processRequests(client TTransport) error {
-	defer p.Done()
-
-	processor := p.processorFactory.GetProcessor(client)
-	inputTransport, err := p.inputTransportFactory.GetTransport(client)
-	if err != nil {
-		return err
-	}
-	outputTransport, err := p.outputTransportFactory.GetTransport(client)
-	if err != nil {
-		return err
-	}
-	inputProtocol := p.inputProtocolFactory.GetProtocol(inputTransport)
-	outputProtocol := p.outputProtocolFactory.GetProtocol(outputTransport)
-	defer func() {
-		if e := recover(); e != nil {
-			log.Printf("panic in processor: %s: %s", e, debug.Stack())
-		}
-	}()
-
-	if inputTransport != nil {
-		defer inputTransport.Close()
-	}
-	if outputTransport != nil {
-		defer outputTransport.Close()
-	}
-	for {
-		select {
-		case <-p.quit:
-			return nil
-		default:
-		}
-
-		ctx := context.Background()
-		ok, err := processor.Process(ctx, inputProtocol, outputProtocol)
-		if err, ok := err.(TTransportException); ok && err.TypeId() == END_OF_FILE {
-			return nil
-		} else if err != nil {
-			return err
-		}
-		if err, ok := err.(TApplicationException); ok && err.TypeId() == UNKNOWN_METHOD {
-			continue
-		}
-		if !ok {
-			break
-		}
-	}
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/lib/go/thrift/simple_server_test.go
----------------------------------------------------------------------
diff --git a/lib/go/thrift/simple_server_test.go b/lib/go/thrift/simple_server_test.go
index 8763a3b..25702e4 100644
--- a/lib/go/thrift/simple_server_test.go
+++ b/lib/go/thrift/simple_server_test.go
@@ -24,14 +24,6 @@ import (
 	"time"
 )
 
-type mockProcessor struct {
-	ProcessFunc func(in, out TProtocol) (bool, TException)
-}
-
-func (m *mockProcessor) Process(in, out TProtocol) (bool, TException) {
-	return m.ProcessFunc(in, out)
-}
-
 type mockServerTransport struct {
 	ListenFunc    func() error
 	AcceptFunc    func() (TTransport, error)

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/test/go/Makefile.am
----------------------------------------------------------------------
diff --git a/test/go/Makefile.am b/test/go/Makefile.am
index 2b2dbce..4285359 100644
--- a/test/go/Makefile.am
+++ b/test/go/Makefile.am
@@ -20,7 +20,7 @@
 BUILT_SOURCES = gopath
 
 THRIFT = $(top_builddir)/compiler/cpp/thrift
-THRIFTCMD = $(THRIFT) -out src/gen --gen go:thrift_import=thrift
+THRIFTCMD = $(THRIFT) -out src/gen --gen go:thrift_import=thrift,legacy_context
 THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
 
 precross: bin/testclient bin/testserver
@@ -35,6 +35,7 @@ gopath: $(THRIFT) ThriftTest.thrift
 	$(THRIFTCMD) ../StressTest.thrift
 	ln -nfs ../../../lib/go/thrift src/thrift
 	GOPATH=`pwd` $(GO) get github.com/golang/mock/gomock
+	GOPATH=`pwd` $(GO) get golang.org/x/net/context
 	touch gopath
 
 bin/testclient: gopath

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/test/go/src/bin/stress/go17.go
----------------------------------------------------------------------
diff --git a/test/go/src/bin/stress/go17.go b/test/go/src/bin/stress/go17.go
new file mode 100644
index 0000000..81f1ad8
--- /dev/null
+++ b/test/go/src/bin/stress/go17.go
@@ -0,0 +1,62 @@
+// +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"
+	"sync/atomic"
+)
+
+type handler struct{}
+
+func (h *handler) EchoVoid(ctx context.Context) (err error) {
+	atomic.AddInt64(&counter, 1)
+	return nil
+}
+func (h *handler) EchoByte(ctx context.Context, arg int8) (r int8, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoI32(ctx context.Context, arg int32) (r int32, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoI64(ctx context.Context, arg int64) (r int64, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoString(ctx context.Context, arg string) (r string, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoList(ctx context.Context, arg []int8) (r []int8, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoSet(ctx context.Context, arg map[int8]struct{}) (r map[int8]struct{}, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoMap(ctx context.Context, arg map[int8]int8) (r map[int8]int8, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/test/go/src/bin/stress/main.go
----------------------------------------------------------------------
diff --git a/test/go/src/bin/stress/main.go b/test/go/src/bin/stress/main.go
index 1f713bb..e8e6b2a 100644
--- a/test/go/src/bin/stress/main.go
+++ b/test/go/src/bin/stress/main.go
@@ -216,38 +216,3 @@ func client(protocolFactory thrift.TProtocolFactory) {
 
 	done.Done()
 }
-
-type handler struct{}
-
-func (h *handler) EchoVoid() (err error) {
-	atomic.AddInt64(&counter, 1)
-	return nil
-}
-func (h *handler) EchoByte(arg int8) (r int8, err error) {
-	atomic.AddInt64(&counter, 1)
-	return arg, nil
-}
-func (h *handler) EchoI32(arg int32) (r int32, err error) {
-	atomic.AddInt64(&counter, 1)
-	return arg, nil
-}
-func (h *handler) EchoI64(arg int64) (r int64, err error) {
-	atomic.AddInt64(&counter, 1)
-	return arg, nil
-}
-func (h *handler) EchoString(arg string) (r string, err error) {
-	atomic.AddInt64(&counter, 1)
-	return arg, nil
-}
-func (h *handler) EchoList(arg []int8) (r []int8, err error) {
-	atomic.AddInt64(&counter, 1)
-	return arg, nil
-}
-func (h *handler) EchoSet(arg map[int8]struct{}) (r map[int8]struct{}, err error) {
-	atomic.AddInt64(&counter, 1)
-	return arg, nil
-}
-func (h *handler) EchoMap(arg map[int8]int8) (r map[int8]int8, err error) {
-	atomic.AddInt64(&counter, 1)
-	return arg, nil
-}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/test/go/src/bin/stress/pre_go17.go
----------------------------------------------------------------------
diff --git a/test/go/src/bin/stress/pre_go17.go b/test/go/src/bin/stress/pre_go17.go
new file mode 100644
index 0000000..07ae5c6
--- /dev/null
+++ b/test/go/src/bin/stress/pre_go17.go
@@ -0,0 +1,63 @@
+// +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 (
+	"sync/atomic"
+
+	"golang.org/x/net/context"
+)
+
+type handler struct{}
+
+func (h *handler) EchoVoid(ctx context.Context) (err error) {
+	atomic.AddInt64(&counter, 1)
+	return nil
+}
+func (h *handler) EchoByte(ctx context.Context, arg int8) (r int8, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoI32(ctx context.Context, arg int32) (r int32, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoI64(ctx context.Context, arg int64) (r int64, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoString(ctx context.Context, arg string) (r string, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoList(ctx context.Context, arg []int8) (r []int8, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoSet(ctx context.Context, arg map[int8]struct{}) (r map[int8]struct{}, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}
+func (h *handler) EchoMap(ctx context.Context, arg map[int8]int8) (r map[int8]int8, err error) {
+	atomic.AddInt64(&counter, 1)
+	return arg, nil
+}

http://git-wip-us.apache.org/repos/asf/thrift/blob/c0d384a3/test/go/src/common/clientserver_test.go
----------------------------------------------------------------------
diff --git a/test/go/src/common/clientserver_test.go b/test/go/src/common/clientserver_test.go
index 9f490ea..acc3dba 100644
--- a/test/go/src/common/clientserver_test.go
+++ b/test/go/src/common/clientserver_test.go
@@ -92,32 +92,32 @@ var xcept = &thrifttest.Xception{ErrorCode: 1001, Message: "some"}
 
 func callEverythingWithMock(t *testing.T, client *thrifttest.ThriftTestClient, handler *MockThriftTest) {
 	gomock.InOrder(
-		handler.EXPECT().TestVoid(),
-		handler.EXPECT().TestString("thing").Return("thing", nil),
-		handler.EXPECT().TestBool(true).Return(true, nil),
-		handler.EXPECT().TestBool(false).Return(false, nil),
-		handler.EXPECT().TestByte(int8(42)).Return(int8(42), nil),
-		handler.EXPECT().TestI32(int32(4242)).Return(int32(4242), nil),
-		handler.EXPECT().TestI64(int64(424242)).Return(int64(424242), nil),
+		handler.EXPECT().TestVoid(gomock.Any()),
+		handler.EXPECT().TestString(gomock.Any(), "thing").Return("thing", nil),
+		handler.EXPECT().TestBool(gomock.Any(), true).Return(true, nil),
+		handler.EXPECT().TestBool(gomock.Any(), false).Return(false, nil),
+		handler.EXPECT().TestByte(gomock.Any(), int8(42)).Return(int8(42), nil),
+		handler.EXPECT().TestI32(gomock.Any(), int32(4242)).Return(int32(4242), nil),
+		handler.EXPECT().TestI64(gomock.Any(), int64(424242)).Return(int64(424242), nil),
 		// TODO: add TestBinary()
-		handler.EXPECT().TestDouble(float64(42.42)).Return(float64(42.42), nil),
-		handler.EXPECT().TestStruct(&thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}).Return(&thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}, nil),
-		handler.EXPECT().TestNest(&thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}).Return(&thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}, nil),
-		handler.EXPECT().TestMap(map[int32]int32{1: 2, 3: 4, 5: 42}).Return(map[int32]int32{1: 2, 3: 4, 5: 42}, nil),
-		handler.EXPECT().TestStringMap(map[string]string{"a": "2", "b": "blah", "some": "thing"}).Return(map[string]string{"a": "2", "b": "blah", "some": "thing"}, nil),
-		handler.EXPECT().TestSet([]int32{1, 2, 42}).Return([]int32{1, 2, 42}, nil),
-		handler.EXPECT().TestList([]int32{1, 2, 42}).Return([]int32{1, 2, 42}, nil),
-		handler.EXPECT().TestEnum(thrifttest.Numberz_TWO).Return(thrifttest.Numberz_TWO, nil),
-		handler.EXPECT().TestTypedef(thrifttest.UserId(42)).Return(thrifttest.UserId(42), nil),
-		handler.EXPECT().TestMapMap(int32(42)).Return(rmapmap, nil),
+		handler.EXPECT().TestDouble(gomock.Any(), float64(42.42)).Return(float64(42.42), nil),
+		handler.EXPECT().TestStruct(gomock.Any(), &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}).Return(&thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}, nil),
+		handler.EXPECT().TestNest(gomock.Any(), &thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}).Return(&thrifttest.Xtruct2{StructThing: &thrifttest.Xtruct{StringThing: "thing", ByteThing: 42, I32Thing: 4242, I64Thing: 424242}}, nil),
+		handler.EXPECT().TestMap(gomock.Any(), map[int32]int32{1: 2, 3: 4, 5: 42}).Return(map[int32]int32{1: 2, 3: 4, 5: 42}, nil),
+		handler.EXPECT().TestStringMap(gomock.Any(), map[string]string{"a": "2", "b": "blah", "some": "thing"}).Return(map[string]string{"a": "2", "b": "blah", "some": "thing"}, nil),
+		handler.EXPECT().TestSet(gomock.Any(), []int32{1, 2, 42}).Return([]int32{1, 2, 42}, nil),
+		handler.EXPECT().TestList(gomock.Any(), []int32{1, 2, 42}).Return([]int32{1, 2, 42}, nil),
+		handler.EXPECT().TestEnum(gomock.Any(), thrifttest.Numberz_TWO).Return(thrifttest.Numberz_TWO, nil),
+		handler.EXPECT().TestTypedef(gomock.Any(), thrifttest.UserId(42)).Return(thrifttest.UserId(42), nil),
+		handler.EXPECT().TestMapMap(gomock.Any(), int32(42)).Return(rmapmap, nil),
 		// TODO: not testing insanity
-		handler.EXPECT().TestMulti(int8(42), int32(4242), int64(424242), map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24)).Return(xxs, nil),
-		handler.EXPECT().TestException("some").Return(xcept),
-		handler.EXPECT().TestException("TException").Return(errors.New("Just random exception")),
-		handler.EXPECT().TestMultiException("Xception", "ignoreme").Return(nil, &thrifttest.Xception{ErrorCode: 1001, Message: "This is an Xception"}),
-		handler.EXPECT().TestMultiException("Xception2", "ignoreme").Return(nil, &thrifttest.Xception2{ErrorCode: 2002, StructThing: &thrifttest.Xtruct{StringThing: "This is an Xception2"}}),
-		handler.EXPECT().TestOneway(int32(2)).Return(nil),
-		handler.EXPECT().TestVoid(),
+		handler.EXPECT().TestMulti(gomock.Any(), int8(42), int32(4242), int64(424242), map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24)).Return(xxs, nil),
+		handler.EXPECT().TestException(gomock.Any(), "some").Return(xcept),
+		handler.EXPECT().TestException(gomock.Any(), "TException").Return(errors.New("Just random exception")),
+		handler.EXPECT().TestMultiException(gomock.Any(), "Xception", "ignoreme").Return(nil, &thrifttest.Xception{ErrorCode: 1001, Message: "This is an Xception"}),
+		handler.EXPECT().TestMultiException(gomock.Any(), "Xception2", "ignoreme").Return(nil, &thrifttest.Xception2{ErrorCode: 2002, StructThing: &thrifttest.Xtruct{StringThing: "This is an Xception2"}}),
+		handler.EXPECT().TestOneway(gomock.Any(), int32(2)).Return(nil),
+		handler.EXPECT().TestVoid(gomock.Any()),
 	)
 	var err error
 	if err = client.TestVoid(); err != nil {