Documentation ¶
Overview ¶
The fakenet package provides a way to turn a regular io.ReadWriter into a net.Conn, including support for timeouts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("operation on closed channel")
Functions ¶
func NewConn ¶
func NewConn(r io.ReadCloser, w io.WriteCloser, local, remote net.Addr) net.Conn
NewConn returns a net.Conn using r for reading and w for writing.
Local and remote give the addresses that will be returned from the respective methods of the connection. If either is nil, Addr("fakenet") will be used.
Types ¶
type ChanReader ¶
type ChanReader struct {
// contains filtered or unexported fields
}
A ChanReader reads from a chan []byte to satisfy Read requests.
func NewChanReader ¶
func NewChanReader(c <-chan []byte) *ChanReader
NewChanReader creates a new ChanReader that reads from the given channel.
func (*ChanReader) Close ¶
func (r *ChanReader) Close() error
Close implements the net.Conn Close method.
func (*ChanReader) Read ¶
func (r *ChanReader) Read(buf []byte) (int, error)
Read implements the net.Conn Read method.
func (*ChanReader) SetReadDeadline ¶
func (r *ChanReader) SetReadDeadline(t time.Time) error
SetReadDeadline implements the net.Conn SetReadDeadline method.
type ChanWriter ¶
type ChanWriter struct {
// contains filtered or unexported fields
}
A ChanWriter writes to a chan []byte to satisfy Write requests.
func NewChanWriter ¶
func NewChanWriter(c chan<- []byte) *ChanWriter
NewChanWriter creates a new ChanWriter that writes to the given channel.
func (*ChanWriter) Close ¶
func (w *ChanWriter) Close() error
Close implements the net.Conn Close method.
func (*ChanWriter) SetWriteDeadline ¶
func (w *ChanWriter) SetWriteDeadline(t time.Time) error
SetWriteDeadline implements the net.Conn SetWriteDeadline method.