From 4bc0711281828327e78c10b8c280675e47e6cc23 Mon Sep 17 00:00:00 2001 From: cuishuang Date: Fri, 11 Apr 2025 18:15:39 +0800 Subject: acme: use built-in max/min to simplify the code Change-Id: I6ba8d07b9e53b01f25f4c1c8eac629aaa47de3a1 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/664836 LUCI-TryBot-Result: Go LUCI Reviewed-by: Roland Shoemaker Reviewed-by: Dmitri Shuralyov --- acme/http.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/acme/http.go b/acme/http.go index d92ff23..8f29df5 100644 --- a/acme/http.go +++ b/acme/http.go @@ -66,7 +66,7 @@ func (c *Client) retryTimer() *retryTimer { // The n argument is always bounded between 1 and 30. // The returned value is always greater than 0. func defaultBackoff(n int, r *http.Request, res *http.Response) time.Duration { - const max = 10 * time.Second + const maxVal = 10 * time.Second var jitter time.Duration if x, err := rand.Int(rand.Reader, big.NewInt(1000)); err == nil { // Set the minimum to 1ms to avoid a case where @@ -86,10 +86,7 @@ func defaultBackoff(n int, r *http.Request, res *http.Response) time.Duration { n = 30 } d := time.Duration(1< max { - return max - } - return d + return min(d, maxVal) } // retryAfter parses a Retry-After HTTP header value, -- cgit v1.3