title: Copying stdin to a buffer
body: <p>I want to copy a <code>os.Stdin</code> string to a buffer, to check for a user inputted text (e.g. "hibye") and put an if statement against it.</p>
  
  <p>My current code just handles simple stdin stdiout copy operations (no buffer):</p>
  
  <pre><code>func interact(c net.Conn) {
      // Read from Reader and write to Writer until EOF()
      copy := func(r io.ReadCloser, w io.WriteCloser) {
          defer func() {
              r.Close()
              w.Close()
          }()
          n, err := io.Copy(w, r)
          if err != nil {
              log.Printf("[%s]: ERROR: %s\n", c.RemoteAddr(), err)
              log.Println(n)
          }
      }
  
      go copy(c, os.Stdout)
      go copy(os.Stdin, c)
  }
  </code></pre>
  
  <p><strong>Question:</strong> What is the most efficient way to implement a use of a buffer to have control over the passed strings?</p>
  
  <p>bad example (failed attempt):</p>
  
  <pre><code>buf := make([]byte, 1024)
  go copy (os.Stdin, []byte(buf))
  if buf == "hibye" {
  do stuff
  }
  </code></pre>