是否多个goroutine会同时在Conn上调用方法?

My program like this:

func handle(conn net.Conn) {
    msg := "hello, world!"
    for i:= 0; i< 100000; i++ {
        go func() {
            err := write(conn, msg)
        }
    }

}
func write(conn net.Conn, msg string) error {
    mlen := fmt.Sprintf("%04d", len(msg))

    _, err := conn.Write([]byte(mlen + msg))
    return err
}

The program will run 100000 goroutines at same time, and all goroutines will send message to the same connection。 I am doubt that server will receive error message like "hellohelloworldworld", but there is no problem when the program run in my Ubuntu 14.04LTS.

So, Do multiple goroutine will invoke a method on a Conn simultaneously?

=========================================================================

How can I keep the Write method atomic?

The documentation states:

Multiple goroutines may invoke methods on a Conn simultaneously.

There is no mention of whether each individual write is atomic. While the current implementation may ensure that each call to Write happens completely before the next call can begin, there is no guarantee in the language specification.