diff --git a/README.md b/README.md index db120c9..0a976b2 100644 --- a/README.md +++ b/README.md @@ -32,22 +32,6 @@ Import: import "gopkg.in/redis.v5" ``` -## Vendoring - -If you are using a vendoring tool with support for semantic versioning -e.g. [glide](https://github.com/Masterminds/glide), you can import this -package via its GitHub URL: - -```yaml -- package: github.com/go-redis/redis - version: ^5.0.0 -``` - -WARNING: please note that by importing `github.com/go-redis/redis` -directly (without semantic versioning constrol) you are in danger of -running in the breaking API changes. Use carefully and at your own -risk! - ## Quickstart ```go diff --git a/example_test.go b/example_test.go index 0769aa0..8f35f2f 100644 --- a/example_test.go +++ b/example_test.go @@ -331,3 +331,21 @@ func ExampleScanCmd_Iterator() { panic(err) } } + +func ExampleClient_instrumentation() { + client := redis.NewClient(&redis.Options{ + Addr: ":6379", + }) + client.WrapProcess(func(oldProcess func(cmd redis.Cmder) error) func(cmd redis.Cmder) error { + return func(cmd redis.Cmder) error { + start := time.Now() + err := oldProcess(cmd) + if err != nil { + fmt.Printf("command %s failed: %s", cmd, err) + } else { + fmt.Printf("command %q took %s", cmd, time.Since(start)) + } + return err + } + }) +} diff --git a/internal/proto/proto.go b/internal/proto/proto.go index e1c1ed4..b51e4e8 100644 --- a/internal/proto/proto.go +++ b/internal/proto/proto.go @@ -8,8 +8,8 @@ import ( "gopkg.in/redis.v5/internal" ) -func Scan(s string, val interface{}) error { - switch v := val.(type) { +func Scan(s string, v interface{}) error { + switch v := v.(type) { case nil: return internal.RedisError("redis: Scan(nil)") case *string: @@ -99,12 +99,10 @@ func Scan(s string, val interface{}) error { case *bool: *v = len(s) == 1 && s[0] == '1' return nil + case encoding.BinaryUnmarshaler: + return v.UnmarshalBinary([]byte(s)) default: - if bu, ok := val.(encoding.BinaryUnmarshaler); ok { - return bu.UnmarshalBinary([]byte(s)) - } - err := fmt.Errorf( - "redis: can't unmarshal %T (consider implementing BinaryUnmarshaler)", val) - return err + return fmt.Errorf( + "redis: can't unmarshal %T (consider implementing BinaryUnmarshaler)", v) } } diff --git a/redis.go b/redis.go index aee3893..72b8ee6 100644 --- a/redis.go +++ b/redis.go @@ -1,4 +1,4 @@ -package redis +package redis // import "gopkg.in/redis.v5" import ( "fmt"