THRIFT-2497 server and client for test/go, also several fixes and improvements
Client: Go
Patch: Aleksey Pesternikov

This closes #109

commit f2e7186ca8d63f407dba0c56ee51afd6405926ba
 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net>
 Date: 2014-04-22T12:48:14Z

add _ to generated filename if it ends with _test.go

commit a6ed88196fbf4622a3b0261bbac0fe6b258bdd36
 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net>
 Date: 2014-04-22T14:19:13Z

use tcxx instead of tr1 in test/cpp

commit d1848fa05f4baefc66eb405f4b1a8657bb2869bd
 Author: Aleksey Pesternikov <ap@alekseys-macbook-pro.local>
 Date: 2014-04-23T01:01:03Z

Merge branch 'master' of https://github.com/apache/thrift into go_integration

commit 04d22fef228d3f868b32a296a38f99ff52ee2142
 Author: Aleksey Pesternikov <ap@alekseys-macbook-pro.local>
 Date: 2014-04-25T00:34:24Z

additions:
 test for client/server with several protocol/transport/ssl combinations
 bin/testclient and bin/testserver
 debug_transport

fixes:
 separate Listen() and AcceptLoop() instead of Serve() in SimpleServer
 if handler function returns any unknown exception, handler closes connection

commit ed88d57d977cffea9fac8f61143801f3097ef46c
 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net>
 Date: 2014-04-25T13:29:54Z

Generate lowercase package name
 lowercased pkg name in thrift files
 underline() -> lowercase()

commit 498a910c6c6753a4b1e3633eb5c9c82be33e8c7b
 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net>
 Date: 2014-04-25T13:32:26Z

Merge branch 'master' into go_test_service_name

commit 25792d7218a2c32ee3c2077f65ca7d0cea7f31f5
 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net>
 Date: 2014-04-22T12:48:14Z

add _ to generated filename if it ends with _test.go

commit af994b415308a2e174d57a03675fc83d7cbd43d1
 Author: Aleksey Pesternikov <ap@alekseys-macbook-pro.local>
 Date: 2014-04-25T00:34:24Z

additions:
 test for client/server with several protocol/transport/ssl combinations
 bin/testclient and bin/testserver
 debug_transport

fixes:
 separate Listen() and AcceptLoop() instead of Serve() in SimpleServer
 if handler function returns any unknown exception, handler closes connection

commit f22a777a5d5b4d93a8d7981e7aadc2c63919518a
 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net>
 Date: 2014-04-25T13:44:08Z

Merge branch 'go_integration' of github.com:apesternikov/thrift into go_integration

commit 49a33c8c80ea35f923ee9aa3577780fcf41fe840
 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net>
 Date: 2014-04-25T13:49:05Z

Merge branch 'master' into test_cpp_on_mac

commit 81b402ec6301f6b132c9b346ad5481f55f0aff89
 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net>
 Date: 2014-04-25T13:56:56Z

operator < for ThriftTest

commit cde312d940d12077274dd0ba677ca850b5b439a7
 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net>
 Date: 2014-04-25T14:12:58Z

minor formatting

commit 0a693115c2c20a2a8375f3859ff7bed261e6c8da
 Author: Aleksey Pesternikov <ap@alekseys-mbp.att.net>
 Date: 2014-04-25T14:13:20Z

Merge branch 'test_cpp_on_mac' into go_integration

commit e06b5d24e8b6d429723a3c77a58c6ce903e1366a
 Author: Aleksey Pesternikov <ap@alekseys-macbook-pro.local>
 Date: 2014-04-25T15:19:20Z

Merge branch 'go_test_service_name' into go_integration

commit 42d577c9812a070060c773fcd0598e58e6d6ba61
 Author: Aleksey Pesternikov <ap@alekseys-macbook-pro.local>
 Date: 2014-04-25T15:39:57Z

imported THRIFT-2491
 lowercase package names

commit 491ccf8b018c046c5ced72b1e19d9ac4ec48a6f5
 Author: Aleksey Pesternikov <ap@alekseys-macbook-pro.local>
 Date: 2014-04-25T15:51:53Z

--noinsane flag for c++ TestClient. works with go server now for other default params

commit 78db3c9a3a5742818a5de6e57f2fe9aed84919e5
 Author: Aleksey Pesternikov <ap@alekseys-macbook-pro.local>
 Date: 2014-04-25T16:03:23Z

license
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()
+}