title: how to notify TCP client the end of the file in golang?
body: <p>I want to send a file through TCP in golang.
  here's my server code:</p>
  
  <pre><code>    c is connected *net.TCPConn
  
      file, _ := os.Open(fn)
      defer file.Close()
      io.Copy(c, file)
      // c.CloseWrite()
  </code></pre>
  
  <p>and client:</p>
  
  <pre><code>    as above, c is connected *net.TCPConn
  
      file, _ := os.Create("file.txt")
      defer file.Close()
      io.Copy(file, c)
  </code></pre>
  
  <p>my question is: in this way, the client can not receive the EOF of the file</p>
  
  <p>so, <code>io.Copy</code> blocked. I have to call <code>c.CloseWrite</code> to notify client that the file is over.</p>
  
  <p>If I want to send files, this will not work, How can I solve this?</p>