Why does conn.Read() write nothing into a []byte, but bufio.Reader.ReadString() works?
<p>I have a connection, created like this:</p>

<pre><code>conn, err = net.Dial("tcp", "127.0.0.1:20000")
</code></pre>

<p>I have tried reading from this connection in two ways. I think they both must work, but the first option doesn't.</p>

<p>Here is the first way of doing it:</p>

<pre><code>var bytes []byte
for i := 0; i &lt; 4; i++ {
    conn.Read(bytes)
}
fmt.Printf("%v", bytes)
</code></pre>

<p>The output of this method is:</p>

<pre><code>[]
</code></pre>

<p>And here is the same thing, done with <code>bufio.Reader</code>:</p>

<pre><code>func readResponse(conn net.Conn) (response string, err error) {
    reader := bufio.NewReader(conn)
    _, err = reader.Discard(8)
    if err != nil {
        return
    }

    response, err = reader.ReadString('\n')

    return
}
</code></pre>

<p>This function returns the response given by the server on the other end of the TCP connection.</p>

<p>Why does <code>bufio.Reader.Read()</code> work, but <code>net.Conn.Read()</code> doesn't?</p>