【论坛、网站】:
一、数组及Slice
参考:http://www.jb51.net/article/57121.htm
二、go func问题 及 defer
func Server(listen *net.TCPListener) { for { conn, err := listen.AcceptTCP() if err != nil { fmt.Println("AcceptTCP_Err:", err.Error()) continue } fmt.Println("AcceptTCP_From:", conn.RemoteAddr().String()) defer conn.Close() go func() { data := make([]byte, 128) for { i, err := conn.Read(data) fmt.Println("AcceptTCP_data:", string(data[0:i])) if err != nil { fmt.Println("AcceptTCP_ReadErr:", err.Error()) break } conn.Write([]byte{'f', 'i', 'n', 'i', 's', 'h'}) } }() } }