client: encourage error handling in package doc

This commit is contained in:
Brian Waldon 2015-01-28 12:58:58 -08:00 committed by Yicheng Qin
parent 6fd105d554
commit 2b5589ddcd

View File

@ -39,10 +39,16 @@ Create a KeysAPI using the Client, then use it to interact with etcd:
kAPI := client.NewKeysAPI(c)
// create a new key /foo with the value "bar"
kAPI.Create(context.Background(), "/foo", "bar")
_, err = kAPI.Create(context.Background(), "/foo", "bar")
if err != nil {
// handle error
}
// delete the newly created key only if the value is still "bar"
kAPI.Delete(context.Background(), "/foo", &DeleteOptions{PrevValue: "bar"})
_, err = kAPI.Delete(context.Background(), "/foo", &DeleteOptions{PrevValue: "bar"})
if err != nil {
// handle error
}
Use a custom context to set timeouts on your operations: