req
req copied to clipboard
比隔壁resty性能要好一些
简单地测试了一下,比resty性能要好一些
resty实例设置一个超时都要加一下锁
// SetTimeout method is used to set a timeout for a request raised by the client.
//
// client.SetTimeout(1 * time.Minute)
//
// It can be overridden at the request level. See [Request.SetTimeout]
//
// NOTE: Resty uses [context.WithTimeout] on the request, it does not use [http.Client].Timeout
func (c *Client) SetTimeout(timeout time.Duration) *Client {
c.lock.Lock()
defer c.lock.Unlock()
c.timeout = timeout
return c
}