Skip to content

Instantly share code, notes, and snippets.

@martinomburajr
Last active May 14, 2019 05:07
Show Gist options
  • Select an option

  • Save martinomburajr/2911c57bddce0790322d635afe3a50e7 to your computer and use it in GitHub Desktop.

Select an option

Save martinomburajr/2911c57bddce0790322d635afe3a50e7 to your computer and use it in GitHub Desktop.
Reader implementation in the net.Conn
// Read implements the Conn Read method.
func (c *conn) Read(b []byte) (int, error) {
if !c.ok() {
return 0, syscall.EINVAL
}
n, err := c.fd.Read(b)
if err != nil && err != io.EOF {
err = &OpError{Op: "read",
Net: c.fd.net,
Source: c.fd.laddr,
Addr: c.fd.raddr,
Err: err}
}
return n, err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment