title: How does one test net.Conn in unit tests in Golang?
body: <p>I'm currently looking into creating some unit tests for net.Conn interface in Go, as well as other functions that build up on top of that functionality, and I'm wondering what is the best way to unit test that in Google Go? My code looks like:</p>
  
  <pre><code>conn, _:=net.Dial("tcp", "127.0.0.1:8080")
  ...
  fmt.Fprintf(conn, "test")
  ...
  buffer:=make([]byte, 100)
  conn.Read(buffer)
  </code></pre>
  
  <p>Is the most efficient way of testing this code and the code that uses these functions to spin up a separate goroutine to act like the server, use <a href="https://golang.org/pkg/net/http/httptest/" rel="noreferrer">net.http.httptest package</a>, or something else?</p>