Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use time.Until(deadline) instead of -time.Since(deadline) #1434

Merged
merged 1 commit into from Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions client.go
Expand Up @@ -907,7 +907,7 @@ type clientURLResponse struct {
}

func clientGetURLDeadline(dst []byte, url string, deadline time.Time, c clientDoer) (statusCode int, body []byte, err error) {
timeout := -time.Since(deadline)
timeout := time.Until(deadline)
if timeout <= 0 {
return 0, dst, ErrTimeout
}
Expand Down Expand Up @@ -2361,7 +2361,7 @@ func (c *PipelineClient) DoDeadline(req *Request, resp *Response, deadline time.
func (c *pipelineConnClient) DoDeadline(req *Request, resp *Response, deadline time.Time) error {
c.init()

timeout := -time.Since(deadline)
timeout := time.Until(deadline)
if timeout < 0 {
return ErrTimeout
}
Expand Down
2 changes: 1 addition & 1 deletion fasthttputil/pipeconns.go
Expand Up @@ -266,7 +266,7 @@ func updateTimer(t *time.Timer, deadline time.Time) <-chan time.Time {
if deadline.IsZero() {
return nil
}
d := -time.Since(deadline)
d := time.Until(deadline)
if d <= 0 {
return closedDeadlineCh
}
Expand Down
2 changes: 1 addition & 1 deletion tcpdialer.go
Expand Up @@ -309,7 +309,7 @@ func (d *TCPDialer) dial(addr string, dualStack bool, timeout time.Duration) (ne
}

func (d *TCPDialer) tryDial(network string, addr *net.TCPAddr, deadline time.Time, concurrencyCh chan struct{}) (net.Conn, error) {
timeout := -time.Since(deadline)
timeout := time.Until(deadline)
if timeout <= 0 {
return nil, ErrDialTimeout
}
Expand Down