Skip to content

Commit 4880a15

Browse files
Copilotnomeguy
andcommitted
Extract timeout duration as named constant
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
1 parent b3b0f04 commit 4880a15

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

smtp.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import (
1212
"golang.org/x/net/proxy"
1313
)
1414

15+
const (
16+
// smtpClientTimeout is the timeout for SMTP client creation
17+
smtpClientTimeout = 5 * time.Second
18+
)
19+
1520
// A Dialer is a dialer to an SMTP server.
1621
type Dialer struct {
1722
// Host represents the host of the SMTP server.
@@ -94,7 +99,7 @@ func (d *Dialer) Dial() (SendCloser, error) {
9499
}
95100

96101
// Set a 5-second timeout for SMTP client creation
97-
if err := conn.SetDeadline(time.Now().Add(5 * time.Second)); err != nil {
102+
if err := conn.SetDeadline(time.Now().Add(smtpClientTimeout)); err != nil {
98103
conn.Close()
99104
return nil, err
100105
}

0 commit comments

Comments
 (0)