github.com/go-email-validator/go-email-validator@v0.0.0-20230409163946-b8b9e6a0552e/test/mock/net/interface.go (about) 1 package mocknet 2 3 import ( 4 "net" 5 "time" 6 ) 7 8 // Conn is copy interface from built-in library net.Conn. 9 // Need to generate mock 10 type Conn interface { 11 // Read reads data from the connection. 12 // Read can be made to time out and return an error after a fixed 13 // time limit; see SetDeadline and SetReadDeadline. 14 Read(b []byte) (n int, err error) 15 16 // Write writes data to the connection. 17 // Write can be made to time out and return an error after a fixed 18 // time limit; see SetDeadline and SetWriteDeadline. 19 Write(b []byte) (n int, err error) 20 21 // Close closes the connection. 22 // Any blocked Read or Write operations will be unblocked and return errors. 23 Close() error 24 25 // LocalAddr returns the local network address. 26 LocalAddr() net.Addr 27 28 // RemoteAddr returns the remote network address. 29 RemoteAddr() net.Addr 30 31 // SetDeadline sets the read and write deadlines associated 32 // with the connection. It is equivalent to calling both 33 // SetReadDeadline and SetWriteDeadline. 34 // 35 // A deadline is an absolute time after which I/O operations 36 // fail instead of blocking. The deadline applies to all future 37 // and pending I/O, not just the immediately following call to 38 // Read or Write. After a deadline has been exceeded, the 39 // connection can be refreshed by setting a deadline in the future. 40 // 41 // If the deadline is exceeded a call to Read or Write or to other 42 // I/O methods will return an error that wraps os.ErrDeadlineExceeded. 43 // This can be tested using errors.Is(err, os.ErrDeadlineExceeded). 44 // The error's Timeout method will return true, but note that there 45 // are other possible errors for which the Timeout method will 46 // return true even if the deadline has not been exceeded. 47 // 48 // An idle timeout can be implemented by repeatedly extending 49 // the deadline after successful Read or Write calls. 50 // 51 // A zero value for t means I/O operations will not time out. 52 SetDeadline(t time.Time) error 53 54 // SetReadDeadline sets the deadline for future Read calls 55 // and any currently-blocked Read call. 56 // A zero value for t means Read will not time out. 57 SetReadDeadline(t time.Time) error 58 59 // SetWriteDeadline sets the deadline for future Write calls 60 // and any currently-blocked Write call. 61 // Even if write times out, it may return n > 0, indicating that 62 // some of the data was successfully written. 63 // A zero value for t means Write will not time out. 64 SetWriteDeadline(t time.Time) error 65 }