From bf1b8cf0338b427af3885f4f318b5ab144bc6a05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Devrim=20=C5=9Eahin?= Date: Thu, 8 Feb 2024 21:07:11 +0300 Subject: [PATCH] Avoid concrete net.Dialer type for easier mocking --- pop3.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pop3.go b/pop3.go index 6d4c876..e7e313a 100644 --- a/pop3.go +++ b/pop3.go @@ -18,7 +18,7 @@ import ( // Client implements a Client e-mail client. type Client struct { opt Opt - dialer *net.Dialer + dialer Dialer } // Conn is a stateful connection with the POP3 server/ @@ -35,12 +35,16 @@ type Opt struct { // Default is 3 seconds. DialTimeout time.Duration `json:"dial_timeout"` - Dialer *net.Dialer `json:"-"` + Dialer Dialer `json:"-"` TLSEnabled bool `json:"tls_enabled"` TLSSkipVerify bool `json:"tls_skip_verify"` } +type Dialer interface { + Dial(network, address string) (net.Conn, error) +} + // MessageID contains the ID and size of an individual message. type MessageID struct { // ID is the numerical index (non-unique) of the message.