Handle error in api README example

This commit is contained in:
Mikhail Dyakov 2015-10-23 21:20:01 +02:00
parent 6a350d5d19
commit 01aba571a1
1 changed files with 8 additions and 3 deletions

View File

@ -17,13 +17,18 @@ Usage
Below is an example of using the Consul client:
```go
// Get a new client, with KV endpoints
client, _ := api.NewClient(api.DefaultConfig())
// Get a new client
client, err := api.NewClient(api.DefaultConfig())
if err != nil {
panic(err)
}
// Get a handle to the KV API
kv := client.KV()
// PUT a new KV pair
p := &api.KVPair{Key: "foo", Value: []byte("test")}
_, err := kv.Put(p, nil)
_, err = kv.Put(p, nil)
if err != nil {
panic(err)
}