Skip to content

Commit

Permalink
add nil check for LocalAddr (#907)
Browse files Browse the repository at this point in the history
  • Loading branch information
shohi committed Nov 7, 2020
1 parent 30aa43e commit c2542e5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tcpdialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,11 @@ func (d *TCPDialer) tryDial(network string, addr *net.TCPAddr, deadline time.Tim
defer func() { <-concurrencyCh }()
}

dialer := net.Dialer{LocalAddr: d.LocalAddr}
dialer := net.Dialer{}
if d.LocalAddr != nil {
dialer.LocalAddr = d.LocalAddr
}

ctx, cancel_ctx := context.WithDeadline(context.Background(), deadline)
defer cancel_ctx()
conn, err := dialer.DialContext(ctx, network, addr.String())
Expand Down

0 comments on commit c2542e5

Please sign in to comment.