From a7373c42bb6424e060cdb28b2274a65228434f66 Mon Sep 17 00:00:00 2001
From: Pawan Rawal <pawan0201@gmail.com>
Date: Tue, 26 Apr 2016 20:35:07 +0530
Subject: [PATCH] Added new file client.go and client_test.go and moved
 relevant code there.

---
 client/client.go                           | 42 ++++++++++++++++++++++
 client/{go/main_test.go => client_test.go} |  2 +-
 client/go/main.go                          | 23 ------------
 3 files changed, 43 insertions(+), 24 deletions(-)
 create mode 100644 client/client.go
 rename client/{go/main_test.go => client_test.go} (99%)

diff --git a/client/client.go b/client/client.go
new file mode 100644
index 00000000..41e7f304
--- /dev/null
+++ b/client/client.go
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016 DGraph Labs, Inc.
+ *
+ * Licensed 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 client
+
+import "github.com/dgraph-io/dgraph/query/pb"
+
+func NumChildren(resp *pb.GraphResponse) int {
+	return len(resp.Children)
+}
+
+func HasValue(resp *pb.GraphResponse) bool {
+	for _, val := range resp.Result.Values {
+		if len(val) > 0 {
+			return true
+		}
+	}
+	return false
+}
+
+func Values(resp *pb.GraphResponse) []string {
+	values := []string{}
+	for _, val := range resp.Result.Values {
+		if len(val) > 0 {
+			values = append(values, string(val))
+		}
+	}
+	return values
+}
diff --git a/client/go/main_test.go b/client/client_test.go
similarity index 99%
rename from client/go/main_test.go
rename to client/client_test.go
index 02fb0348..345f62ac 100644
--- a/client/go/main_test.go
+++ b/client/client_test.go
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-package main
+package client
 
 import (
 	"io/ioutil"
diff --git a/client/go/main.go b/client/go/main.go
index a82cea80..4d8ac267 100644
--- a/client/go/main.go
+++ b/client/go/main.go
@@ -31,29 +31,6 @@ var glog = x.Log("client")
 var ip = flag.String("ip", "127.0.0.1:8081", "Port to communicate with server")
 var q = flag.String("query", "", "Query sent to the server")
 
-func NumChildren(resp *pb.GraphResponse) int {
-	return len(resp.Children)
-}
-
-func HasValue(resp *pb.GraphResponse) bool {
-	for _, val := range resp.Result.Values {
-		if len(val) > 0 {
-			return true
-		}
-	}
-	return false
-}
-
-func Values(resp *pb.GraphResponse) []string {
-	values := []string{}
-	for _, val := range resp.Result.Values {
-		if len(val) > 0 {
-			values = append(values, string(val))
-		}
-	}
-	return values
-}
-
 func main() {
 	flag.Parse()
 	// TODO(pawan): Pick address for server from config
-- 
GitLab