Created
October 1, 2016 17:43
-
-
Save clsung/fa8ce3b40be7887881e54d8682f3bdfe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Values is a helper that converts an array command reply to a []interface{}. | |
// If err is not equal to nil, then Values returns nil, err. Otherwise, Values | |
// converts the reply as follows: | |
// | |
// Reply type Result | |
// array reply, nil | |
// nil nil, ErrNil | |
// other nil, error | |
func Values(reply interface{}, err error) ([]interface{}, error) { | |
if err != nil { | |
return nil, err | |
} | |
switch reply := reply.(type) { | |
case []interface{}: | |
return reply, nil | |
case nil: | |
return nil, ErrNil | |
case Error: | |
return nil, reply | |
} | |
return nil, fmt.Errorf("redigo: unexpected type for Values, got type %T", reply) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment