mock_conn

package module
v0.0.0-...-817fbee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2018 License: MIT Imports: 4 Imported by: 0

README

Mock connection for Golang

This is a simple simulation connection for mocking a net.Conn in golang.

Inspired by this StackOverflow question

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr struct {
	NetworkString string
	AddrString    string
}

Addr is a fake network interface which implements the net.Addr interface

func (Addr) Network

func (a Addr) Network() string

func (Addr) String

func (a Addr) String() string

type Conn

type Conn struct {
	Server *End
	Client *End
}

MockConn facilitates testing by providing two connected ReadWriteClosers each of which can be used in place of a net.Conn

func NewConn

func NewConn() *Conn

func (*Conn) Close

func (c *Conn) Close() error

type End

type End struct {
	Reader         *io.PipeReader
	Writer         *io.PipeWriter
	BufferedWriter *concurrent.Writer
}

End is one 'end' of a simulated connection.

func (End) Close

func (c End) Close() error

func (End) LocalAddr

func (e End) LocalAddr() net.Addr

func (End) Read

func (e End) Read(data []byte) (n int, err error)

func (End) RemoteAddr

func (e End) RemoteAddr() net.Addr

func (End) SetDeadline

func (e End) SetDeadline(t time.Time) error

func (End) SetReadDeadline

func (e End) SetReadDeadline(t time.Time) error

func (End) SetWriteDeadline

func (e End) SetWriteDeadline(t time.Time) error

func (End) Write

func (e End) Write(data []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL