zeebo/bencode

Decode from bytes

liamzebedee opened this issue · 1 comments

I think it would be good to add some sort of helper function in the form:

func NewDecoderFromBytes(data []byte) *Decoder {
    reader := bytes.NewBuffer(data)
    return NewDecoder(reader)
}

I frequently find myself using this and it would assist in shorthand for RawMessage processing.

I don't really want to complicate the api. I like how concise it is. EncodeString and DecodeString are already pushing it, and its not too hard to wrap a []byte in a bytes.Reader. In fact, just copying that function you wrote into some code fixes the problem already :)