How can I properly write the `Read` and `Write` the `net.Pipe()`
<p>I'm trying out the <code>net.Pipe()</code>.  I thought writing the <code>"haha"</code> string and then reading it back might be a good experiment.</p>

<p>Here is my first version.  It blocks on the <code>Write</code></p>

<pre><code>func TestNetPipe(t *testing.T) {
    out1 := make([]byte, 10) 
    c1, c2 := net.Pipe()
    c1.Write([]byte("haha"))
    c2.Read(out1)
}
</code></pre>

<p>I tried to use a goroutine</p>

<pre><code>func TestNetPipe(t *testing.T) {
    out1 := make([]byte, 10) 
    c1, c2 := net.Pipe()
    go func() {
        c1.Write([]byte("haha"))
    }() 
    fmt.Printf("%v\n", out1)
    c2.Read(out1)
    fmt.Printf("%v\n", out1)
}
</code></pre>

<p>It works. But I felt there is no guarantee that the <code>Read</code> will read the whole <code>"haha"</code> string. It might only read the <code>"hah"</code> part.</p>

<p>I'm wondering if there is a better way to demo the usage of <code>net.Pipe()</code></p>