🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
``` package main import ( "fmt" "net" ) func main() { conn, err := net.Dial("tcp", "127.0.0.1:8080") if err != nil{ fmt.Println("conn err :", err) return } defer conn.Close() conn.Write([]byte("hello tcp server")) buf := make([]byte, 4096) n, err := conn.Read(buf) if err != nil{ fmt.Println("read err : ", err) return } fmt.Println("server send msg :", string(buf[:n])) } ```