mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #8039 from heyitsanthony/client-example-sort
client: sort nodes in example
This commit is contained in:
commit
7350525937
@ -17,6 +17,7 @@ package client_test
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"sort"
|
||||||
|
|
||||||
"github.com/coreos/etcd/client"
|
"github.com/coreos/etcd/client"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
@ -55,6 +56,7 @@ func ExampleKeysAPI_directory() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
// print directory keys
|
// print directory keys
|
||||||
|
sort.Sort(resp.Node.Nodes)
|
||||||
for _, n := range resp.Node.Nodes {
|
for _, n := range resp.Node.Nodes {
|
||||||
fmt.Printf("Key: %q, Value: %q\n", n.Key, n.Value)
|
fmt.Printf("Key: %q, Value: %q\n", n.Key, n.Value)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user