128的slice,尽管string()之后,他还是不等于 "timestamp"。
This commit is contained in:
Lane
2015-12-02 16:05:20 +08:00
parent d324024be1
commit 07db159ef7

View File

@@ -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 {