From bead8d1ea2e40549355aff5d9f5f8fc65138f6ca Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Mon, 4 Nov 2013 09:47:36 +0200 Subject: [PATCH] Improve pipelined example. --- v2/example_test.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/v2/example_test.go b/v2/example_test.go index 0b5aa39..df3c301 100644 --- a/v2/example_test.go +++ b/v2/example_test.go @@ -38,13 +38,13 @@ func ExampleClient() { defer client.Close() set := client.Set("foo", "bar") - fmt.Println(set.Err(), set.Val()) + fmt.Println(set.Val(), set.Err()) get := client.Get("foo") - fmt.Println(get.Err(), get.Val()) + fmt.Println(get.Val(), get.Err()) - // Output: OK - // bar + // Output: OK + // bar } func ExampleClient_Pipelined() { @@ -55,10 +55,12 @@ func ExampleClient_Pipelined() { cmds, err := client.Pipelined(func(c *redis.Pipeline) { c.Set("key1", "hello1") - c.Get("key2") + c.Get("key1") }) - fmt.Println(cmds, err) - // Output: [SET key1 hello1: OK GET key2: (nil)] (nil) + set := cmds[0].(*redis.StatusCmd) + get := cmds[1].(*redis.StringCmd) + fmt.Println(set, get, err) + // Output: SET key1 hello1: OK GET key1: hello1 } func ExamplePipeline() {