去写套接字-无效的参数

Im trying to write to a TCP socket in Go but only receive "invalid argument" with this code:

_, err := conn.Write([]byte("test"))
if err != nil {
    fmt.Println(err.Error())
}

Here is a simple sample of what you want to do(maybe?), be aware that you should make a tcp server listen to the port 8999 first before run it

nc -l 8999     #or maybe nc -l -p 8999 

code:

package main

import (
    "net"
)

func main() {
    conn, _ := net.Dial("tcp", "localhost:8999")
    conn.Write([]byte("test"))
}

If it's not your question, you should provide more information.