WithTimeout returns a ClientOptionsFunc that sets the timeout for a Client. This overrides the timeout set by [WithHTTPClient]. If not set and no HTTP client is provided, the default http.Client with no timeout will be used. It is recommended to provide a timeout for production environments.
(timeout time.Duration)
| 395 | // client is provided, the default http.Client with no timeout will be used. |
| 396 | // It is recommended to provide a timeout for production environments. |
| 397 | func WithTimeout(timeout time.Duration) ClientOptionsFunc { |
| 398 | return func(o *clientOptions) error { |
| 399 | if timeout < 0 { |
| 400 | return errors.New("timeout must not be negative") |
| 401 | } |
| 402 | |
| 403 | o.timeout = &timeout |
| 404 | return nil |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | // WithUserAgent returns a ClientOptionsFunc that sets the User-Agent header |
| 409 | // for a Client. If not set, a default User-Agent will be used. |
no outgoing calls
searching dependent graphs…