From fc8d3a64d69d0eb08783d1cbe85bc2b3835a49e8 Mon Sep 17 00:00:00 2001
From: longganhua <long>
Date: 星期四, 18 七月 2019 14:31:22 +0800
Subject: [PATCH] syncdb.go

---
 command/query.go |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/command/query.go b/command/query.go
index 2e023c7..c8ad299 100644
--- a/command/query.go
+++ b/command/query.go
@@ -3,11 +3,11 @@
 import (
 	"flag"
 	"fmt"
+	"io/ioutil"
 	"strings"
 	"time"
 
-	"io/ioutil"
-
+	sdb "basic.com/pubsub/syncdb.git/db"
 	"github.com/hashicorp/serf/client"
 	"github.com/hashicorp/serf/cmd/serf/command/agent"
 	"github.com/mitchellh/cli"
@@ -107,18 +107,7 @@
 		payload = []byte(args[1])
 	}
 
-	//file to []byte
-
-	buf, err := ioutil.ReadFile("10M.jpg")
-	if err != nil {
-		c.Ui.Error(fmt.Sprintf("Error: %s", err))
-		return 1
-	}
-	_ = buf
- 
-	//payload = buf
-	fmt.Println("len(payload): ", len(payload))
-
+	fmt.Println("query send len payload", len(payload))
 	cl, err := RPCClient(*rpcAddr, *rpcAuth)
 	if err != nil {
 		c.Ui.Error(fmt.Sprintf("Error connecting to Serf agent: %s", err))
@@ -179,6 +168,7 @@
 				break OUTER
 			}
 			handler.ResponseReceived(r)
+			fmt.Println("enter respch: r.payload", r.Payload)
 
 		case <-c.ShutdownCh:
 			return 1
@@ -231,6 +221,22 @@
 		payload = payload[:n-1]
 	}
 
+	/**   my self example*/
+	fmt.Println("x length is: ", payload)
+
+	// // byte to file.
+	sdb.Dbconn.Close()
+	sdb.Dbconn = nil
+	err := ioutil.WriteFile("test.db", payload, 0644)
+	if err != nil {
+		fmt.Println("query byte to file error!", err)
+	}
+	err = sdb.GetConn()
+	if err != nil {
+		fmt.Println("create db conn of test.db error: ", err)
+	}
+	/*   my self example*/
+
 	t.ui.Info(fmt.Sprintf("Response from '%s': %s", r.From, payload))
 }
 

--
Gitblit v1.8.0