THRIFT-2012 Modernizing Go

Patch: Travis Cline
diff --git a/tutorial/go/src/client.go b/tutorial/go/src/client.go
new file mode 100644
index 0000000..114de19
--- /dev/null
+++ b/tutorial/go/src/client.go
@@ -0,0 +1,85 @@
+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 (
+	"fmt"
+	"git.apache.org/thrift.git/lib/go/thrift"
+	"tutorial"
+)
+
+func handleClient(client *tutorial.CalculatorClient) (err error) {
+	client.Ping()
+	fmt.Println("ping()")
+
+	sum, _ := client.Add(1, 1)
+	fmt.Print("1+1=", sum, "\n")
+
+	work := tutorial.NewWork()
+	work.Op = tutorial.Operation_DIVIDE
+	work.Num1 = 1
+	work.Num2 = 0
+	quotient, ouch, err := client.Calculate(1, work)
+	if err != nil {
+		fmt.Println("Error during operation:", err)
+		return err
+	} else if ouch != nil {
+		fmt.Println("Invalid operation:", ouch)
+	} else {
+		fmt.Println("Whoa we can divide by 0 with new value:", quotient)
+	}
+
+	work.Op = tutorial.Operation_SUBTRACT
+	work.Num1 = 15
+	work.Num2 = 10
+	diff, ouch, err := client.Calculate(1, work)
+	if err != nil {
+		fmt.Println("Error during operation:", err)
+		return err
+	} else if ouch != nil {
+		fmt.Println("Invalid operation:", ouch)
+	} else {
+		fmt.Print("15-10=", diff, "\n")
+	}
+
+	log, err := client.GetStruct(1)
+	if err != nil {
+		fmt.Println("Unable to get struct:", err)
+		return err
+	} else {
+		fmt.Println("Check log:", log.Value)
+	}
+	return err
+}
+
+func runClient(transportFactory thrift.TTransportFactory, protocolFactory thrift.TProtocolFactory) error {
+	var transport thrift.TTransport
+	transport, err := thrift.NewTSocket("localhost:9090")
+	if err != nil {
+		fmt.Println("Error opening socket:", err)
+		return err
+	}
+	transport = transportFactory.GetTransport(transport)
+	defer transport.Close()
+	if err := transport.Open(); err != nil {
+		return err
+	}
+	return handleClient(tutorial.NewCalculatorClientFactory(transport, protocolFactory))
+}