Expand documentation for NewClient

Also adds a reference to the godoc for the (now old) NewClient method.
This commit is contained in:
Ben Tranter 2020-03-16 11:30:42 -04:00
parent 014c98ed83
commit e1575cffe0
No known key found for this signature in database
GPG Key ID: 354C06FAA2EF2AF1
2 changed files with 8 additions and 1 deletions

View File

@ -51,6 +51,8 @@ func main() {
}
```
If you need to provide a `context.Context` to your new client, you should use [`godo.NewClient`](https://godoc.org/github.com/digitalocean/godo#NewClient) to manually construct a client instead.
## Examples

View File

@ -169,7 +169,12 @@ func NewFromToken(token string) *Client {
return NewClient(oauth2.NewClient(ctx, ts))
}
// NewClient returns a new DigitalOcean API client.
// NewClient returns a new DigitalOcean API client, using the given
// http.Client to perform all requests.
//
// Users who wish to pass their own http.Client should use this method. If
// you're in need of further customization, the godo.New method allows more
// options, such as setting a custom URL or a custom user agent string.
func NewClient(httpClient *http.Client) *Client {
if httpClient == nil {
httpClient = http.DefaultClient