```go
package main
import (
"csxieyi/protocol"
"fmt"
"net"
"os"
"strconv"
"time"
)
func send(conn net.Conn) {
for i := 0; i < 100; i++ {
session := GetSession()
这里错误 : messages := "{\"session":session"}\"
conn.Write(protocol.Enpack([]byte(messages)))
}
fmt.Println("send over")
defer conn.Close()
}
func GetSession() string {
gs1 := time.Now().Unix()
gs2 := strconv.FormatInt(gs1, 10)
return gs2
}
func main() {
server := ":7758"
tcpAddr, err := net.ResolveTCPAddr("tcp4", server)
if err != nil {
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
os.Exit(1)
}
conn, err := net.DialTCP("tcp", nil, tcpAddr)
if err != nil {
fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error())
os.Exit(1)
}
fmt.Println("connect success")
send(conn)
}
```
.\main.go:16: syntax error: unexpected : at end of statement
.\main.go:16: newline in string
有疑问加站长微信联系(非本文作者)