diff --git a/test/go/Makefile.am b/test/go/Makefile.am
new file mode 100644
index 0000000..4875757
--- /dev/null
+++ b/test/go/Makefile.am
@@ -0,0 +1,58 @@
+#
+# 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.
+#
+
+THRIFT = $(top_srcdir)/compiler/cpp/thrift
+THRIFTCMD = $(THRIFT) -out src/gen --gen go:thrift_import=thrift
+THRIFTTEST = $(top_srcdir)/test/ThriftTest.thrift
+
+all: bin/testclient bin/testserver bin/stress
+
+ThriftTest.thrift: $(THRIFTTEST)
+	grep -v list.*map.*list.*map $(THRIFTTEST) > ThriftTest.thrift
+
+# Thrift for GO has problems with complex map keys: THRIFT-2063
+gopath: $(THRIFT) ThriftTest.thrift 
+	$(THRIFTCMD) ThriftTest.thrift
+	$(THRIFTCMD) ../StressTest.thrift
+	ln -nfs ../../../lib/go/thrift src/thrift
+	GOPATH=`pwd` $(GO) get code.google.com/p/gomock/gomock
+	touch gopath
+
+bin/testclient: gopath
+	GOPATH=`pwd` $(GO) install bin/testclient
+
+bin/testserver: gopath
+	GOPATH=`pwd` $(GO) install bin/testserver
+
+bin/stress: gopath
+	GOPATH=`pwd` $(GO) install bin/stress
+
+clean-local:
+	$(RM) -r src/gen/* src/code.google.com src/thrift bin pkg gopath ThriftTest.thrift
+
+check: gopath
+	GOPATH=`pwd` $(GO) test -v common/...
+
+genmock: gopath
+	GOPATH=`pwd` $(GO) install code.google.com/p/gomock/mockgen
+	GOPATH=`pwd` bin/mockgen -destination=src/common/mock_handler.go -package=common gen/thrifttest ThriftTest
+
+EXTRA_DIST = \
+	IncludesTest.thrift \
+	NamespacedTest.thrift
diff --git a/test/go/src/bin/stress/main.go b/test/go/src/bin/stress/main.go
new file mode 100644
index 0000000..4fc88e0
--- /dev/null
+++ b/test/go/src/bin/stress/main.go
@@ -0,0 +1,254 @@
+/*
+ * 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 (
+	"flag"
+	"fmt"
+	"gen/stress"
+	"log"
+	_ "net/http/pprof"
+	"os"
+	"runtime"
+	"runtime/pprof"
+	"sync"
+	"sync/atomic"
+	"thrift"
+	"time"
+)
+
+var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to this file")
+var memprofile = flag.String("memprofile", "", "write memory profile to this file")
+
+var (
+	host      = flag.String("host", "localhost", "Host to connect")
+	port      = flag.Int64("port", 9091, "Port number to connect")
+	loop      = flag.Int("loops", 50000, "The number of remote thrift calls each client makes")
+	runserver = flag.Int("server", 1, "Run the Thrift server in this process")
+	clients   = flag.Int("clients", 20, "Number of client threads to create - 0 implies no clients, i.e. server only")
+	callName  = flag.String("call", "echoVoid", "Service method to call, one of echoVoid, echoByte, echoI32, echoI64, echoString, echiList, echoSet, echoMap")
+	compact   = flag.Bool("compact", false, "Use compact protocol instead of binary.")
+	framed    = flag.Bool("framed", false, "Use framed transport instead of buffered.")
+)
+var hostPort string
+
+type callT int64
+
+const (
+	echoVoid callT = iota
+	echoByte
+	echoI32
+	echoI64
+	echoString
+	echiList
+	echoSet
+	echoMap
+)
+
+var callTMap = map[string]callT{
+	"echoVoid":   echoVoid,
+	"echoByte":   echoByte,
+	"echoI32":    echoI32,
+	"echoI64":    echoI64,
+	"echoString": echoString,
+	"echiList":   echiList,
+	"echoSet":    echoSet,
+	"echoMap":    echoMap,
+}
+var callType callT
+
+var ready, done sync.WaitGroup
+
+var clicounter int64 = 0
+var counter int64 = 0
+
+func main() {
+	flag.Parse()
+	if *memprofile != "" {
+		runtime.MemProfileRate = 100
+	}
+	var ok bool
+	if callType, ok = callTMap[*callName]; !ok {
+		log.Fatal("Unknown service call", *callName)
+	}
+	if *cpuprofile != "" {
+		f, err := os.Create(*cpuprofile)
+		if err != nil {
+			log.Fatal(err)
+		}
+		pprof.StartCPUProfile(f)
+		defer pprof.StopCPUProfile()
+	}
+	hostPort = fmt.Sprintf("%s:%d", *host, *port)
+	var protocolFactory thrift.TProtocolFactory
+	var transportFactory thrift.TTransportFactory
+
+	if *compact {
+		protocolFactory = thrift.NewTCompactProtocolFactory()
+	} else {
+		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
+	}
+
+	if *framed {
+		transportFactory = thrift.NewTTransportFactory()
+		transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
+	} else {
+		transportFactory = thrift.NewTBufferedTransportFactory(8192)
+	}
+
+	if *runserver > 0 {
+		serverTransport, err := thrift.NewTServerSocket(hostPort)
+		if err != nil {
+			log.Fatalf("Unable to create server socket: %s", err)
+		}
+
+		processor := stress.NewServiceProcessor(&handler{})
+		server := thrift.NewTSimpleServer4(processor, serverTransport, transportFactory, protocolFactory)
+		if *clients == 0 {
+			server.Serve()
+		} else {
+			go server.Serve()
+		}
+	}
+	//start clients
+	if *clients != 0 {
+		ready.Add(*clients + 1)
+		done.Add(*clients)
+		for i := 0; i < *clients; i++ {
+			go client(protocolFactory)
+		}
+		ready.Done()
+		ready.Wait()
+		//run!
+		startTime := time.Now()
+		//wait for completion
+		done.Wait()
+		endTime := time.Now()
+		duration := endTime.Sub(startTime)
+		log.Printf("%d calls in %v (%f calls per second)\n", clicounter, duration, float64(clicounter)/duration.Seconds())
+	}
+	if *memprofile != "" {
+		f, err := os.Create(*memprofile)
+		if err != nil {
+			log.Fatal(err)
+		}
+		pprof.WriteHeapProfile(f)
+		f.Close()
+		return
+	}
+}
+
+func client(protocolFactory thrift.TProtocolFactory) {
+	trans, err := thrift.NewTSocket(hostPort)
+	if err != nil {
+		log.Fatalf("Unable to create server socket: %s", err)
+	}
+	btrans := thrift.NewTBufferedTransport(trans, 2048)
+	client := stress.NewServiceClientFactory(btrans, protocolFactory)
+	err = trans.Open()
+	if err != nil {
+		log.Fatalf("Unable to open connection: %s", err)
+	}
+	ready.Done()
+	ready.Wait()
+	switch callType {
+	case echoVoid:
+		for i := 0; i < *loop; i++ {
+			client.EchoVoid()
+			atomic.AddInt64(&clicounter, 1)
+		}
+	case echoByte:
+		for i := 0; i < *loop; i++ {
+			client.EchoByte(42)
+			atomic.AddInt64(&clicounter, 1)
+		}
+	case echoI32:
+		for i := 0; i < *loop; i++ {
+			client.EchoI32(4242)
+			atomic.AddInt64(&clicounter, 1)
+		}
+	case echoI64:
+		for i := 0; i < *loop; i++ {
+			client.EchoI64(424242)
+			atomic.AddInt64(&clicounter, 1)
+		}
+	case echoString:
+		for i := 0; i < *loop; i++ {
+			client.EchoString("TestString")
+			atomic.AddInt64(&clicounter, 1)
+		}
+	case echiList:
+		l := []int8{-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8}
+		for i := 0; i < *loop; i++ {
+			client.EchoList(l)
+			atomic.AddInt64(&clicounter, 1)
+		}
+	case echoSet:
+		s := map[int8]bool{-10: true, -9: true, -8: true, -7: true, -6: true, -5: true, -4: true, -3: true, -2: true, -1: true, 0: true, 1: true, 2: true, 3: true, 4: true, 5: true, 6: true, 7: true, 8: true}
+		for i := 0; i < *loop; i++ {
+			client.EchoSet(s)
+			atomic.AddInt64(&clicounter, 1)
+		}
+	case echoMap:
+		m := map[int8]int8{
+			-10: 10, -9: 9, -8: 8, -7: 7, -6: 6, -5: 5, -4: 4, -3: 3, -2: 2, -1: 1, 0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8}
+		for i := 0; i < *loop; i++ {
+			client.EchoMap(m)
+			atomic.AddInt64(&clicounter, 1)
+		}
+	}
+
+	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]bool) (r map[int8]bool, 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
+}
diff --git a/test/go/src/bin/testclient/main.go b/test/go/src/bin/testclient/main.go
new file mode 100644
index 0000000..2acf6cf
--- /dev/null
+++ b/test/go/src/bin/testclient/main.go
@@ -0,0 +1,243 @@
+/*
+ * 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 (
+	"common"
+	"flag"
+	"gen/thrifttest"
+	t "log"
+	"reflect"
+	"thrift"
+)
+
+var host = flag.String("host", "localhost", "Host to connect")
+var port = flag.Int64("port", 9090, "Port number to connect")
+var domain_socket = flag.String("domain-socket", "", "Domain Socket (e.g. /tmp/thrifttest.thrift), instead of host and port")
+var transport = flag.String("transport", "buffered", "Transport: buffered, framed, http")
+var protocol = flag.String("protocol", "binary", "Protocol: binary, compact, json")
+var ssl = flag.Bool("ssl", false, "Encrypted Transport using SSL")
+var testloops = flag.Int("testloops", 1, "Number of Tests")
+
+func main() {
+	flag.Parse()
+	client, err := common.StartClient(*host, *port, *domain_socket, *transport, *protocol, *ssl)
+	if err != nil {
+		t.Fatalf("Unable to start client: ", err)
+	}
+	for i := 0; i < *testloops; i++ {
+		callEverything(client)
+	}
+}
+
+var rmapmap = 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},
+}
+
+var xxs = &thrifttest.Xtruct{
+	StringThing: "Hello2",
+	ByteThing:   42,
+	I32Thing:    4242,
+	I64Thing:    424242,
+}
+
+var xcept = &thrifttest.Xception{ErrorCode: 1001, Message: "Xception"}
+
+func callEverything(client *thrifttest.ThriftTestClient) {
+	var err error
+	if err = client.TestVoid(); err != nil {
+		t.Fatalf("Unexpected error in TestVoid() call: ", err)
+	}
+
+	thing, err := client.TestString("thing")
+	if err != nil {
+		t.Fatalf("Unexpected error in TestString() call: ", err)
+	}
+	if thing != "thing" {
+		t.Fatalf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
+	}
+
+	b, err := client.TestByte(42)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestByte() call: ", err)
+	}
+	if b != 42 {
+		t.Fatalf("Unexpected TestByte() result expected 42, got %d ", b)
+	}
+
+	i32, err := client.TestI32(4242)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestI32() call: ", err)
+	}
+	if i32 != 4242 {
+		t.Fatalf("Unexpected TestI32() result expected 4242, got %d ", i32)
+	}
+
+	i64, err := client.TestI64(424242)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestI64() call: ", err)
+	}
+	if i64 != 424242 {
+		t.Fatalf("Unexpected TestI64() result expected 424242, got %d ", i64)
+	}
+
+	d, err := client.TestDouble(42.42)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestDouble() call: ", err)
+	}
+	if d != 42.42 {
+		t.Fatalf("Unexpected TestDouble() result expected 42.42, got %f ", d)
+	}
+
+	xs := thrifttest.NewXtruct()
+	xs.StringThing = "thing"
+	xs.ByteThing = 42
+	xs.I32Thing = 4242
+	xs.I64Thing = 424242
+	xsret, err := client.TestStruct(xs)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestStruct() call: ", err)
+	}
+	if *xs != *xsret {
+		t.Fatalf("Unexpected TestStruct() result expected %#v, got %#v ", xs, xsret)
+	}
+
+	x2 := thrifttest.NewXtruct2()
+	x2.StructThing = xs
+	x2ret, err := client.TestNest(x2)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestNest() call: ", err)
+	}
+	if !reflect.DeepEqual(x2, x2ret) {
+		t.Fatalf("Unexpected TestNest() result expected %#v, got %#v ", x2, x2ret)
+	}
+
+	m := map[int32]int32{1: 2, 3: 4, 5: 42}
+	mret, err := client.TestMap(m)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestMap() call: ", err)
+	}
+	if !reflect.DeepEqual(m, mret) {
+		t.Fatalf("Unexpected TestMap() result expected %#v, got %#v ", m, mret)
+	}
+
+	sm := map[string]string{"a": "2", "b": "blah", "some": "thing"}
+	smret, err := client.TestStringMap(sm)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestStringMap() call: ", err)
+	}
+	if !reflect.DeepEqual(sm, smret) {
+		t.Fatalf("Unexpected TestStringMap() result expected %#v, got %#v ", sm, smret)
+	}
+
+	s := map[int32]bool{1: true, 2: true, 42: true}
+	sret, err := client.TestSet(s)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestSet() call: ", err)
+	}
+	if !reflect.DeepEqual(s, sret) {
+		t.Fatalf("Unexpected TestSet() result expected %#v, got %#v ", s, sret)
+	}
+
+	l := []int32{1, 2, 42}
+	lret, err := client.TestList(l)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestList() call: ", err)
+	}
+	if !reflect.DeepEqual(l, lret) {
+		t.Fatalf("Unexpected TestSet() result expected %#v, got %#v ", l, lret)
+	}
+
+	eret, err := client.TestEnum(thrifttest.Numberz_TWO)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestEnum() call: ", err)
+	}
+	if eret != thrifttest.Numberz_TWO {
+		t.Fatalf("Unexpected TestEnum() result expected %#v, got %#v ", thrifttest.Numberz_TWO, eret)
+	}
+
+	tret, err := client.TestTypedef(thrifttest.UserId(42))
+	if err != nil {
+		t.Fatalf("Unexpected error in TestTypedef() call: ", err)
+	}
+	if tret != thrifttest.UserId(42) {
+		t.Fatalf("Unexpected TestTypedef() result expected %#v, got %#v ", thrifttest.UserId(42), tret)
+	}
+
+	mapmap, err := client.TestMapMap(42)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestMapmap() call: ", err)
+	}
+	if !reflect.DeepEqual(mapmap, rmapmap) {
+		t.Fatalf("Unexpected TestMapmap() result expected %#v, got %#v ", rmapmap, mapmap)
+	}
+
+	xxsret, err := client.TestMulti(42, 4242, 424242, map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24))
+	if err != nil {
+		t.Fatalf("Unexpected error in TestMulti() call: ", err)
+	}
+	if !reflect.DeepEqual(xxs, xxsret) {
+		t.Fatalf("Unexpected TestMulti() result expected %#v, got %#v ", xxs, xxsret)
+	}
+
+	err = client.TestException("Xception")
+	if err == nil {
+		t.Fatalf("Expecting exception in TestException() call")
+	}
+	if !reflect.DeepEqual(err, xcept) {
+		t.Fatalf("Unexpected TestException() result expected %#v, got %#v ", xcept, err)
+	}
+
+	// TODO: connection is being closed on this
+	err = client.TestException("TException")
+	tex, ok := err.(thrift.TApplicationException)
+	if err == nil || !ok || tex.TypeId() != thrift.INTERNAL_ERROR {
+		t.Fatalf("Unexpected TestException() result expected ApplicationError, got %#v ", err)
+	}
+
+	ign, err := client.TestMultiException("Xception", "ignoreme")
+	if ign != nil || err == nil {
+		t.Fatalf("Expecting exception in TestMultiException() call")
+	}
+	if !reflect.DeepEqual(err, &thrifttest.Xception{ErrorCode: 1001, Message: "This is an Xception"}) {
+		t.Fatalf("Unexpected TestMultiException() %#v ", err)
+	}
+
+	ign, err = client.TestMultiException("Xception2", "ignoreme")
+	if ign != nil || err == nil {
+		t.Fatalf("Expecting exception in TestMultiException() call")
+	}
+	expecting := &thrifttest.Xception2{ErrorCode: 2002, StructThing: &thrifttest.Xtruct{StringThing: "This is an Xception2"}}
+
+	if !reflect.DeepEqual(err, expecting) {
+		t.Fatalf("Unexpected TestMultiException() %#v ", err)
+	}
+
+	err = client.TestOneway(2)
+	if err != nil {
+		t.Fatalf("Unexpected error in TestOneway() call: ", err)
+	}
+
+	//Make sure the connection still alive
+	if err = client.TestVoid(); err != nil {
+		t.Fatalf("Unexpected error in TestVoid() call: ", err)
+	}
+}
diff --git a/test/go/src/bin/testserver/main.go b/test/go/src/bin/testserver/main.go
new file mode 100644
index 0000000..cd32f92
--- /dev/null
+++ b/test/go/src/bin/testserver/main.go
@@ -0,0 +1,42 @@
+/*
+ * 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 (
+	"common"
+	"flag"
+	"log"
+)
+
+var host = flag.String("host", "localhost", "Host to connect")
+var port = flag.Int64("port", 9090, "Port number to connect")
+var domain_socket = flag.String("domain-socket", "", "Domain Socket (e.g. /tmp/ThriftTest.thrift), instead of host and port")
+var transport = flag.String("transport", "buffered", "Transport: buffered, framed, http")
+var protocol = flag.String("protocol", "binary", "Protocol: binary, compact, json")
+var ssl = flag.Bool("ssl", false, "Encrypted Transport using SSL")
+
+func main() {
+	flag.Parse()
+	server, err := common.StartServer(*host, *port, *domain_socket, *transport, *protocol, *ssl, common.PrintingHandler)
+	if err != nil {
+		log.Fatalf("Unable to start server: ", err)
+	}
+	server.Serve()
+}
diff --git a/test/go/src/common/client.go b/test/go/src/common/client.go
new file mode 100644
index 0000000..267273e
--- /dev/null
+++ b/test/go/src/common/client.go
@@ -0,0 +1,96 @@
+/*
+ * 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 (
+	"crypto/tls"
+	"flag"
+	"fmt"
+	"gen/thrifttest"
+	"thrift"
+)
+
+var debugClientProtocol bool
+
+func init() {
+	flag.BoolVar(&debugClientProtocol, "debug_client_protocol", false, "turn client protocol trace on")
+}
+
+func StartClient(
+	host string,
+	port int64,
+	domain_socket string,
+	transport string,
+	protocol string,
+	ssl bool) (client *thrifttest.ThriftTestClient, err error) {
+
+	hostPort := fmt.Sprintf("%s:%d", host, port)
+
+	var protocolFactory thrift.TProtocolFactory
+	switch protocol {
+	case "compact":
+		protocolFactory = thrift.NewTCompactProtocolFactory()
+	case "simplejson":
+		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
+	case "json":
+		protocolFactory = thrift.NewTJSONProtocolFactory()
+	case "binary":
+		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
+	default:
+		return nil, fmt.Errorf("Invalid protocol specified %s", protocol)
+	}
+	if debugClientProtocol {
+		protocolFactory = thrift.NewTDebugProtocolFactory(protocolFactory, "client:")
+	}
+	var trans thrift.TTransport
+	if ssl {
+		trans, err = thrift.NewTSSLSocket(hostPort, &tls.Config{InsecureSkipVerify: true})
+	} else {
+		if domain_socket != "" {
+			trans, err = thrift.NewTSocket(domain_socket)
+		} else {
+			trans, err = thrift.NewTSocket(hostPort)
+		}
+	}
+	if err != nil {
+		return nil, err
+	}
+	switch transport {
+	case "http":
+		trans, err = thrift.NewTHttpClient(fmt.Sprintf("http://%s/service", hostPort))
+		if err != nil {
+			return nil, err
+		}
+	case "framed":
+		trans = thrift.NewTFramedTransport(trans)
+	case "buffered":
+		trans = thrift.NewTBufferedTransport(trans, 8192)
+	case "":
+		trans = trans
+	default:
+		return nil, fmt.Errorf("Invalid transport specified %s", transport)
+	}
+
+	if err = trans.Open(); err != nil {
+		return nil, err
+	}
+	client = thrifttest.NewThriftTestClientFactory(trans, protocolFactory)
+	return
+}
diff --git a/test/go/src/common/clientserver_test.go b/test/go/src/common/clientserver_test.go
new file mode 100644
index 0000000..8add041
--- /dev/null
+++ b/test/go/src/common/clientserver_test.go
@@ -0,0 +1,292 @@
+/*
+ * 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 (
+	"code.google.com/p/gomock/gomock"
+	"errors"
+	"gen/thrifttest"
+	"reflect"
+	"testing"
+	"thrift"
+)
+
+type test_unit struct {
+	host          string
+	port          int64
+	domain_socket string
+	transport     string
+	protocol      string
+	ssl           bool
+}
+
+var units = []test_unit{
+	{"127.0.0.1", 9090, "", "", "binary", false},
+	{"127.0.0.1", 9091, "", "", "compact", false},
+	{"127.0.0.1", 9092, "", "", "binary", true},
+	{"127.0.0.1", 9093, "", "", "compact", true},
+}
+
+func TestAllConnection(t *testing.T) {
+	certPath = "../../../keys"
+	for _, unit := range units {
+		t.Logf("%#v", unit)
+		doUnit(t, &unit)
+	}
+}
+
+func doUnit(t *testing.T, unit *test_unit) {
+	ctrl := gomock.NewController(t)
+	defer ctrl.Finish()
+	handler := NewMockThriftTest(ctrl)
+	server, err := StartServer(unit.host, unit.port, unit.domain_socket, unit.transport, unit.protocol, unit.ssl, handler)
+	if err != nil {
+		t.Errorf("Unable to start server", err)
+		t.FailNow()
+	}
+	defer server.Stop()
+	client, err := StartClient(unit.host, unit.port, unit.domain_socket, unit.transport, unit.protocol, unit.ssl)
+	if err != nil {
+		t.Errorf("Unable to start client", err)
+		t.FailNow()
+	}
+	defer client.Transport.Close()
+	callEverythingWithMock(t, client, handler)
+}
+
+var rmapmap = 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},
+}
+
+var xxs = &thrifttest.Xtruct{
+	StringThing: "Hello2",
+	ByteThing:   42,
+	I32Thing:    4242,
+	I64Thing:    424242,
+}
+
+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().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().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(map[int32]bool{1: true, 2: true, 42: true}).Return(map[int32]bool{1: true, 2: true, 42: true}, 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),
+		//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(),
+	)
+	var err error
+	if err = client.TestVoid(); err != nil {
+		t.Errorf("Unexpected error in TestVoid() call: ", err)
+	}
+
+	thing, err := client.TestString("thing")
+	if err != nil {
+		t.Errorf("Unexpected error in TestString() call: ", err)
+	}
+	if thing != "thing" {
+		t.Errorf("Unexpected TestString() result, expected 'thing' got '%s' ", thing)
+	}
+
+	b, err := client.TestByte(42)
+	if err != nil {
+		t.Errorf("Unexpected error in TestByte() call: ", err)
+	}
+	if b != 42 {
+		t.Errorf("Unexpected TestByte() result expected 42, got %d ", b)
+	}
+
+	i32, err := client.TestI32(4242)
+	if err != nil {
+		t.Errorf("Unexpected error in TestI32() call: ", err)
+	}
+	if i32 != 4242 {
+		t.Errorf("Unexpected TestI32() result expected 4242, got %d ", i32)
+	}
+
+	i64, err := client.TestI64(424242)
+	if err != nil {
+		t.Errorf("Unexpected error in TestI64() call: ", err)
+	}
+	if i64 != 424242 {
+		t.Errorf("Unexpected TestI64() result expected 424242, got %d ", i64)
+	}
+
+	d, err := client.TestDouble(42.42)
+	if err != nil {
+		t.Errorf("Unexpected error in TestDouble() call: ", err)
+	}
+	if d != 42.42 {
+		t.Errorf("Unexpected TestDouble() result expected 42.42, got %f ", d)
+	}
+
+	xs := thrifttest.NewXtruct()
+	xs.StringThing = "thing"
+	xs.ByteThing = 42
+	xs.I32Thing = 4242
+	xs.I64Thing = 424242
+	xsret, err := client.TestStruct(xs)
+	if err != nil {
+		t.Errorf("Unexpected error in TestStruct() call: ", err)
+	}
+	if *xs != *xsret {
+		t.Errorf("Unexpected TestStruct() result expected %#v, got %#v ", xs, xsret)
+	}
+
+	x2 := thrifttest.NewXtruct2()
+	x2.StructThing = xs
+	x2ret, err := client.TestNest(x2)
+	if err != nil {
+		t.Errorf("Unexpected error in TestNest() call: ", err)
+	}
+	if !reflect.DeepEqual(x2, x2ret) {
+		t.Errorf("Unexpected TestNest() result expected %#v, got %#v ", x2, x2ret)
+	}
+
+	m := map[int32]int32{1: 2, 3: 4, 5: 42}
+	mret, err := client.TestMap(m)
+	if err != nil {
+		t.Errorf("Unexpected error in TestMap() call: ", err)
+	}
+	if !reflect.DeepEqual(m, mret) {
+		t.Errorf("Unexpected TestMap() result expected %#v, got %#v ", m, mret)
+	}
+
+	sm := map[string]string{"a": "2", "b": "blah", "some": "thing"}
+	smret, err := client.TestStringMap(sm)
+	if err != nil {
+		t.Errorf("Unexpected error in TestStringMap() call: ", err)
+	}
+	if !reflect.DeepEqual(sm, smret) {
+		t.Errorf("Unexpected TestStringMap() result expected %#v, got %#v ", sm, smret)
+	}
+
+	s := map[int32]bool{1: true, 2: true, 42: true}
+	sret, err := client.TestSet(s)
+	if err != nil {
+		t.Errorf("Unexpected error in TestSet() call: ", err)
+	}
+	if !reflect.DeepEqual(s, sret) {
+		t.Errorf("Unexpected TestSet() result expected %#v, got %#v ", s, sret)
+	}
+
+	l := []int32{1, 2, 42}
+	lret, err := client.TestList(l)
+	if err != nil {
+		t.Errorf("Unexpected error in TestList() call: ", err)
+	}
+	if !reflect.DeepEqual(l, lret) {
+		t.Errorf("Unexpected TestSet() result expected %#v, got %#v ", l, lret)
+	}
+
+	eret, err := client.TestEnum(thrifttest.Numberz_TWO)
+	if err != nil {
+		t.Errorf("Unexpected error in TestEnum() call: ", err)
+	}
+	if eret != thrifttest.Numberz_TWO {
+		t.Errorf("Unexpected TestEnum() result expected %#v, got %#v ", thrifttest.Numberz_TWO, eret)
+	}
+
+	tret, err := client.TestTypedef(thrifttest.UserId(42))
+	if err != nil {
+		t.Errorf("Unexpected error in TestTypedef() call: ", err)
+	}
+	if tret != thrifttest.UserId(42) {
+		t.Errorf("Unexpected TestTypedef() result expected %#v, got %#v ", thrifttest.UserId(42), tret)
+	}
+
+	mapmap, err := client.TestMapMap(42)
+	if err != nil {
+		t.Errorf("Unexpected error in TestMapmap() call: ", err)
+	}
+	if !reflect.DeepEqual(mapmap, rmapmap) {
+		t.Errorf("Unexpected TestMapmap() result expected %#v, got %#v ", rmapmap, mapmap)
+	}
+
+	xxsret, err := client.TestMulti(42, 4242, 424242, map[int16]string{1: "blah", 2: "thing"}, thrifttest.Numberz_EIGHT, thrifttest.UserId(24))
+	if err != nil {
+		t.Errorf("Unexpected error in TestMulti() call: ", err)
+	}
+	if !reflect.DeepEqual(xxs, xxsret) {
+		t.Errorf("Unexpected TestMulti() result expected %#v, got %#v ", xxs, xxsret)
+	}
+
+	err = client.TestException("some")
+	if err == nil {
+		t.Errorf("Expecting exception in TestException() call")
+	}
+	if !reflect.DeepEqual(err, xcept) {
+		t.Errorf("Unexpected TestException() result expected %#v, got %#v ", xcept, err)
+	}
+
+	// TODO: connection is being closed on this
+	err = client.TestException("TException")
+	tex, ok := err.(thrift.TApplicationException)
+	if err == nil || !ok || tex.TypeId() != thrift.INTERNAL_ERROR {
+		t.Errorf("Unexpected TestException() result expected ApplicationError, got %#v ", err)
+	}
+
+	ign, err := client.TestMultiException("Xception", "ignoreme")
+	if ign != nil || err == nil {
+		t.Errorf("Expecting exception in TestMultiException() call")
+	}
+	if !reflect.DeepEqual(err, &thrifttest.Xception{ErrorCode: 1001, Message: "This is an Xception"}) {
+		t.Errorf("Unexpected TestMultiException() %#v ", err)
+	}
+
+	ign, err = client.TestMultiException("Xception2", "ignoreme")
+	if ign != nil || err == nil {
+		t.Errorf("Expecting exception in TestMultiException() call")
+	}
+	expecting := &thrifttest.Xception2{ErrorCode: 2002, StructThing: &thrifttest.Xtruct{StringThing: "This is an Xception2"}}
+
+	if !reflect.DeepEqual(err, expecting) {
+		t.Errorf("Unexpected TestMultiException() %#v ", err)
+	}
+
+	err = client.TestOneway(2)
+	if err != nil {
+		t.Errorf("Unexpected error in TestOneway() call: ", err)
+	}
+
+	//Make sure the connection still alive
+	if err = client.TestVoid(); err != nil {
+		t.Errorf("Unexpected error in TestVoid() call: ", err)
+	}
+}
diff --git a/test/go/src/common/mock_handler.go b/test/go/src/common/mock_handler.go
new file mode 100644
index 0000000..0aed38b
--- /dev/null
+++ b/test/go/src/common/mock_handler.go
@@ -0,0 +1,266 @@
+/*
+ * 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.
+ */
+
+// Automatically generated by MockGen. DO NOT EDIT!
+// Source: gen/thrifttest (interfaces: ThriftTest)
+
+package common
+
+import (
+	thrifttest "gen/thrifttest"
+	gomock "code.google.com/p/gomock/gomock"
+)
+
+// Mock of ThriftTest interface
+type MockThriftTest struct {
+	ctrl     *gomock.Controller
+	recorder *_MockThriftTestRecorder
+}
+
+// Recorder for MockThriftTest (not exported)
+type _MockThriftTestRecorder struct {
+	mock *MockThriftTest
+}
+
+func NewMockThriftTest(ctrl *gomock.Controller) *MockThriftTest {
+	mock := &MockThriftTest{ctrl: ctrl}
+	mock.recorder = &_MockThriftTestRecorder{mock}
+	return mock
+}
+
+func (_m *MockThriftTest) EXPECT() *_MockThriftTestRecorder {
+	return _m.recorder
+}
+
+func (_m *MockThriftTest) TestByte(_param0 int8) (int8, error) {
+	ret := _m.ctrl.Call(_m, "TestByte", _param0)
+	ret0, _ := ret[0].(int8)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+func (_mr *_MockThriftTestRecorder) TestByte(arg0 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestByte", arg0)
+}
+
+func (_m *MockThriftTest) TestDouble(_param0 float64) (float64, error) {
+	ret := _m.ctrl.Call(_m, "TestDouble", _param0)
+	ret0, _ := ret[0].(float64)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+func (_mr *_MockThriftTestRecorder) TestDouble(arg0 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestDouble", arg0)
+}
+
+func (_m *MockThriftTest) TestEnum(_param0 thrifttest.Numberz) (thrifttest.Numberz, error) {
+	ret := _m.ctrl.Call(_m, "TestEnum", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestException(_param0 string) error {
+	ret := _m.ctrl.Call(_m, "TestException", _param0)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+func (_mr *_MockThriftTestRecorder) TestException(arg0 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestException", arg0)
+}
+
+func (_m *MockThriftTest) TestI32(_param0 int32) (int32, error) {
+	ret := _m.ctrl.Call(_m, "TestI32", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestI64(_param0 int64) (int64, error) {
+	ret := _m.ctrl.Call(_m, "TestI64", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestInsanity(_param0 *thrifttest.Insanity) (map[thrifttest.UserId]map[thrifttest.Numberz]*thrifttest.Insanity, error) {
+	ret := _m.ctrl.Call(_m, "TestInsanity", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestList(_param0 []int32) ([]int32, error) {
+	ret := _m.ctrl.Call(_m, "TestList", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestMap(_param0 map[int32]int32) (map[int32]int32, error) {
+	ret := _m.ctrl.Call(_m, "TestMap", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestMapMap(_param0 int32) (map[int32]map[int32]int32, error) {
+	ret := _m.ctrl.Call(_m, "TestMapMap", _param0)
+	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)
+}
+
+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)
+	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)
+}
+
+func (_m *MockThriftTest) TestMultiException(_param0 string, _param1 string) (*thrifttest.Xtruct, error) {
+	ret := _m.ctrl.Call(_m, "TestMultiException", _param0, _param1)
+	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)
+}
+
+func (_m *MockThriftTest) TestNest(_param0 *thrifttest.Xtruct2) (*thrifttest.Xtruct2, error) {
+	ret := _m.ctrl.Call(_m, "TestNest", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestOneway(_param0 int32) error {
+	ret := _m.ctrl.Call(_m, "TestOneway", _param0)
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+func (_mr *_MockThriftTestRecorder) TestOneway(arg0 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestOneway", arg0)
+}
+
+func (_m *MockThriftTest) TestSet(_param0 map[int32]bool) (map[int32]bool, error) {
+	ret := _m.ctrl.Call(_m, "TestSet", _param0)
+	ret0, _ := ret[0].(map[int32]bool)
+	ret1, _ := ret[1].(error)
+	return ret0, ret1
+}
+
+func (_mr *_MockThriftTestRecorder) TestSet(arg0 interface{}) *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestSet", arg0)
+}
+
+func (_m *MockThriftTest) TestString(_param0 string) (string, error) {
+	ret := _m.ctrl.Call(_m, "TestString", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestStringMap(_param0 map[string]string) (map[string]string, error) {
+	ret := _m.ctrl.Call(_m, "TestStringMap", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestStruct(_param0 *thrifttest.Xtruct) (*thrifttest.Xtruct, error) {
+	ret := _m.ctrl.Call(_m, "TestStruct", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestTypedef(_param0 thrifttest.UserId) (thrifttest.UserId, error) {
+	ret := _m.ctrl.Call(_m, "TestTypedef", _param0)
+	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)
+}
+
+func (_m *MockThriftTest) TestVoid() error {
+	ret := _m.ctrl.Call(_m, "TestVoid")
+	ret0, _ := ret[0].(error)
+	return ret0
+}
+
+func (_mr *_MockThriftTestRecorder) TestVoid() *gomock.Call {
+	return _mr.mock.ctrl.RecordCall(_mr.mock, "TestVoid")
+}
diff --git a/test/go/src/common/printing_handler.go b/test/go/src/common/printing_handler.go
new file mode 100644
index 0000000..e93621f
--- /dev/null
+++ b/test/go/src/common/printing_handler.go
@@ -0,0 +1,351 @@
+/*
+ * 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 (
+	"errors"
+	"fmt"
+	. "gen/thrifttest"
+	"time"
+)
+
+var PrintingHandler = &printingHandler{}
+
+type printingHandler struct{}
+
+// Prints "testVoid()" and returns nothing.
+func (p *printingHandler) TestVoid() (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(thing string) (r string, err error) {
+	fmt.Printf("testString(\"%s\")\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(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(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(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(thing float64) (r float64, err error) {
+	fmt.Printf("testDouble(%f)\n", thing)
+	return thing, nil
+}
+
+// Prints 'testStruct("{%s}")' where thing has been formatted into a string of comma seperated values
+// @param Xtruct thing - the Xtruct to print
+// @return Xtruct - returns the Xtruct 'thing'
+//
+// Parameters:
+//  - Thing
+func (p *printingHandler) TestStruct(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(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
+//  seperated 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(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
+//  seperated 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(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
+//  seperated 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(thing map[int32]bool) (r map[int32]bool, 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
+//  seperated 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(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(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(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(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(argument *Insanity) (r map[UserId]map[Numberz]*Insanity, err error) {
+	return nil, errors.New("No Insanity")
+}
+
+// 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(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(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(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(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
+}
diff --git a/test/go/src/common/server.go b/test/go/src/common/server.go
new file mode 100644
index 0000000..e77cd37
--- /dev/null
+++ b/test/go/src/common/server.go
@@ -0,0 +1,113 @@
+/*
+ * 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 (
+	"crypto/tls"
+	"flag"
+	"fmt"
+	"gen/thrifttest"
+	"thrift"
+)
+
+var (
+	debugServerProtocol bool
+	certPath            string
+)
+
+func init() {
+	flag.BoolVar(&debugServerProtocol, "debug_server_protocol", false, "turn server protocol trace on")
+}
+
+func StartServer(
+	host string,
+	port int64,
+	domain_socket string,
+	transport string,
+	protocol string,
+	ssl bool,
+	handler thrifttest.ThriftTest) (srv *thrift.TSimpleServer, err error) {
+
+	hostPort := fmt.Sprintf("%s:%d", host, port)
+
+	var protocolFactory thrift.TProtocolFactory
+	switch protocol {
+	case "compact":
+		protocolFactory = thrift.NewTCompactProtocolFactory()
+	case "simplejson":
+		protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
+	case "json":
+		protocolFactory = thrift.NewTJSONProtocolFactory()
+	case "binary":
+		protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
+	default:
+		return nil, fmt.Errorf("Invalid protocol specified %s", protocol)
+	}
+	if debugServerProtocol {
+		protocolFactory = thrift.NewTDebugProtocolFactory(protocolFactory, "server:")
+	}
+
+	var serverTransport thrift.TServerTransport
+	if ssl {
+		cfg := new(tls.Config)
+		if cert, err := tls.LoadX509KeyPair(certPath+"/server.crt", certPath+"/server.key"); err != nil {
+			return nil, err
+		} else {
+			cfg.Certificates = append(cfg.Certificates, cert)
+		}
+		serverTransport, err = thrift.NewTSSLServerSocket(hostPort, cfg)
+	} else {
+		if domain_socket != "" {
+			serverTransport, err = thrift.NewTServerSocket(domain_socket)
+		} else {
+			serverTransport, err = thrift.NewTServerSocket(hostPort)
+		}
+	}
+	if err != nil {
+		return nil, err
+	}
+
+	var transportFactory thrift.TTransportFactory
+
+	switch transport {
+	case "http":
+		return nil, fmt.Errorf("Http server transport is not supported")
+		// trans, err = thrift.NewTHttpClient(fmt.Sprintf("http://%s/service", hostPort))
+		// if err != nil {
+		// 	return nil, err
+		// }
+	case "framed":
+		transportFactory = thrift.NewTTransportFactory()
+		transportFactory = thrift.NewTFramedTransportFactory(transportFactory)
+	case "buffered":
+		transportFactory = thrift.NewTBufferedTransportFactory(8192)
+	case "":
+		transportFactory = thrift.NewTTransportFactory()
+	default:
+		return nil, fmt.Errorf("Invalid transport specified %s", transport)
+	}
+	processor := thrifttest.NewThriftTestProcessor(handler)
+	server := thrift.NewTSimpleServer4(processor, serverTransport, transportFactory, protocolFactory)
+	if err = server.Listen(); err != nil {
+		return
+	}
+	go server.AcceptLoop()
+	return server, nil
+}
diff --git a/test/go/src/common/simple_handler.go b/test/go/src/common/simple_handler.go
new file mode 100644
index 0000000..433616d
--- /dev/null
+++ b/test/go/src/common/simple_handler.go
@@ -0,0 +1,147 @@
+/*
+ * 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 (
+	"errors"
+	. "gen/thrifttest"
+	"time"
+)
+
+var SimpleHandler = &simpleHandler{}
+
+type simpleHandler struct{}
+
+func (p *simpleHandler) TestVoid() (err error) {
+	return nil
+}
+
+func (p *simpleHandler) TestString(thing string) (r string, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestByte(thing int8) (r int8, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestI32(thing int32) (r int32, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestI64(thing int64) (r int64, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestDouble(thing float64) (r float64, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestStruct(thing *Xtruct) (r *Xtruct, err error) {
+	return r, err
+}
+
+func (p *simpleHandler) TestNest(nest *Xtruct2) (r *Xtruct2, err error) {
+	return nest, nil
+}
+
+func (p *simpleHandler) TestMap(thing map[int32]int32) (r map[int32]int32, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestStringMap(thing map[string]string) (r map[string]string, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestSet(thing map[int32]bool) (r map[int32]bool, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestList(thing []int32) (r []int32, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestEnum(thing Numberz) (r Numberz, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestTypedef(thing UserId) (r UserId, err error) {
+	return thing, nil
+}
+
+func (p *simpleHandler) TestMapMap(hello int32) (r map[int32]map[int32]int32, err error) {
+
+	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
+}
+
+func (p *simpleHandler) TestInsanity(argument *Insanity) (r map[UserId]map[Numberz]*Insanity, err error) {
+	return nil, errors.New("No Insanity")
+}
+
+func (p *simpleHandler) TestMulti(arg0 int8, arg1 int32, arg2 int64, arg3 map[int16]string, arg4 Numberz, arg5 UserId) (r *Xtruct, err error) {
+	r = NewXtruct()
+
+	r.StringThing = "Hello2"
+	r.ByteThing = arg0
+	r.I32Thing = arg1
+	r.I64Thing = arg2
+	return
+}
+
+func (p *simpleHandler) TestException(arg string) (err error) {
+	switch arg {
+	case "Xception":
+		e := NewXception()
+		e.ErrorCode = 1001
+		e.Message = arg
+		return e
+	case "TException":
+		return errors.New("Just TException")
+	}
+	return
+}
+
+func (p *simpleHandler) TestMultiException(arg0 string, arg1 string) (r *Xtruct, err error) {
+	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.StringThing = "This is an Xception2"
+		return nil, e
+	default:
+		r = NewXtruct()
+		r.StringThing = arg1
+		return
+	}
+}
+
+func (p *simpleHandler) TestOneway(secondsToSleep int32) (err error) {
+	time.Sleep(time.Second * time.Duration(secondsToSleep))
+	return
+}
