Skip to content

Instantly share code, notes, and snippets.

@bernerdschaefer
Created October 10, 2013 17:12
Show Gist options
  • Save bernerdschaefer/6922041 to your computer and use it in GitHub Desktop.
Save bernerdschaefer/6922041 to your computer and use it in GitHub Desktop.
// like io.Pipe(), but returns two connected ReadWriteClosers.
func newConn() (io.ReadWriteCloser, io.ReadWriteCloser) {
type rwc struct {
io.Reader
io.WriteCloser
}
rs, wc := io.Pipe()
rc, ws := io.Pipe()
return &rwc{rc, wc}, &rwc{rs, ws}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment