From 3084f5d40d41f12f2dd070d0f4aaf8499d68c8e7 Mon Sep 17 00:00:00 2001 From: Lane Date: Wed, 2 Dec 2015 16:05:20 +0800 Subject: [PATCH] Fix Bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 128的slice,尽管string()之后,他还是不等于 "timestamp"。 --- zh/08.1.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zh/08.1.md b/zh/08.1.md index 1e22a96e..fcf9f4c2 100644 --- a/zh/08.1.md +++ b/zh/08.1.md @@ -236,6 +236,7 @@ Go语言中通过net包中的`DialTCP`函数来建立一个TCP连接,并返回 "os" "time" "strconv" + "strings" ) func main() { @@ -267,7 +268,7 @@ Go语言中通过net包中的`DialTCP`函数来建立一个TCP连接,并返回 if read_len == 0 { break // connection already closed by client - } else if string(request) == "timestamp" { + } else if strings.TrimSpace(string(request[:read_len])) == "timestamp" { daytime := strconv.FormatInt(time.Now().Unix(), 10) conn.Write([]byte(daytime)) } else {