+
+ if tr.readOffset >= len(buf) {
+ return 0, io.EOF // All bytes have been read
+ }
+
+ n := copy(p, buf[tr.readOffset:])
+ tr.readOffset += n
+
+ return n, nil
+}
+
+// Dialer interface to abstract the dialing operation
+type Dialer interface {
+ Dial(network, address string) (net.Conn, error)
+}
+
+// RealDialer is the real implementation of the Dialer interface
+type RealDialer struct{}
+
+func (d *RealDialer) Dial(network, address string) (net.Conn, error) {
+ return net.Dial(network, address)