mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #13574 from cunnie/defer_cancel
Golang Client docs: defer `cancel()`, avoid erroring
This commit is contained in:
commit
96a9fd0a1e
@ -47,8 +47,8 @@
|
||||
// To specify a client request timeout, wrap the context with context.WithTimeout:
|
||||
//
|
||||
// ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
// defer cancel()
|
||||
// resp, err := kvc.Put(ctx, "sample_key", "sample_value")
|
||||
// cancel()
|
||||
// if err != nil {
|
||||
// // handle error!
|
||||
// }
|
||||
|
Loading…
x
Reference in New Issue
Block a user