diff --git a/resp.go b/resp.go index 4f58dad..07700bf 100644 --- a/resp.go +++ b/resp.go @@ -20,7 +20,6 @@ const ( Error = '-' ) -// RESP ... type RESP struct { Type Type Raw []byte @@ -40,6 +39,24 @@ func (r *RESP) ForEach(iter func(resp RESP) bool) { } } +func (r *RESP) Bytes() []byte { + return r.Data +} + +func (r *RESP) String() string { + return string(r.Data) +} + +func (r *RESP) Int() int64 { + x, _ := strconv.ParseInt(r.String(), 10, 64) + return x +} + +func (r *RESP) Float() float64 { + x, _ := strconv.ParseFloat(r.String(), 10) + return x +} + // ReadNextRESP returns the next resp in b and returns the number of bytes the // took up the result. func ReadNextRESP(b []byte) (n int, resp RESP) {