package utils import ( "errors" "fmt" ) type Error string func (err Error) Error() string { return string(err) } var ErrNil = errors.New("redigo: nil returned") func Bytes(reply interface{}, err error) ([]byte, error) { if err != nil { return nil, err } switch reply := reply.(type) { case []byte: return reply, nil case string: return []byte(reply), nil case nil: return nil, ErrNil case Error: return nil, reply } return nil, fmt.Errorf("redigo: unexpected type for Bytes, got type %T", reply) }