func decodeValue(r BytesReader) (interface{}, error) {
	ch, err := r.ReadByte()
	if err != nil {
		return nil, err
	}
	var val interface{}
	switch ch {
	case '+':
		val, err = decodeSimpleString(r)
	case '-':
		val, err = decodeError(r)
	case ':':
		val, err = decodeInteger(r)
	case '$':
		val, err = decodeBulkString(r)
	case '*':
		val, err = decodeArray(r)
	default:
		err = ErrInvalidPrefix
	}
	return val, err
}
decodeValue parses the byte slice and decodes the value based on its
prefix, as defined by the RESP protocol.
package resp
import (
	"bytes"
	"errors"
	"fmt"
	"io"
)
var (
	ErrInvalidPrefix = errors.New("resp: invalid prefix")
	ErrMissingCRLF = errors.New("resp: missing CRLF")
	ErrInvalidInteger = errors.New("resp: invalid integer character")
	ErrInvalidBulkString = errors.New("resp: invalid bulk string")
	ErrInvalidArray = errors.New("resp: invalid array")
	ErrNotAnArray = errors.New("resp: expected an array type")
	ErrInvalidRequest = errors.New("resp: invalid request, must be an array of bulk strings with at least one element")
)
type BytesReader interface {
	io.Reader
	io.ByteReader
	ReadBytes(byte) ([]byte, error)
}
type Array []interface{}
func (a Array) String() string {
	var buf bytes.Buffer
	for i, v := range a {
		buf.WriteString(fmt.Sprintf("[%2d] %[2]v (%[2]T)\n", i, v))
	}
	return buf.String()
}
func DecodeRequest(r BytesReader) ([]string, error) {
	val, err := Decode(r)
	if err != nil {
		return nil, err
	}
	ar, ok := val.(Array)
	if !ok {
		return nil, ErrNotAnArray
	}
	if len(ar) < 1 {
		return nil, ErrInvalidRequest
	}
	strs := make([]string, len(ar))
	for i, v := range ar {
		v, ok := v.(string)
		if !ok {
			return nil, ErrInvalidRequest
		}
		strs[i] = v
	}
	return strs, nil
}
func Decode(r BytesReader) (interface{}, error) {
	return decodeValue(r)
}