1
我有一個自定義的http客戶端,它有一個默認的超時值。該代碼是這樣的:我可以檢查一個上下文是否已經超時設置?
type Client struct {
*http.Client
timeout time.Duration
}
func (c *Client) Send(ctx context.Context, r *http.Request) (int, []byte, error) {
// If ctx has timeout set, then don't change it.
// Otherwise, create new context with ctx.WithTimeout(c.timeout)
}
我如何檢查是否已ctx
超時設置或不?