#bytes.NewBuffer that doesn't take ownership

10 messages · Page 1 of 1 (latest)

eager totem
#

I haven't yet found such thing in the stdlib, does it even exist?

plucky cloak
#

What are you trying to do exactly?

eager totem
#

I've got a []byte slice that I need to pass somewhere, but I also have some methods that take in an io.Reader

plucky cloak
#

So you want to implement a reader on a byte slice but you don't want to copy it?

#

You can literally make a new type and implement reader yourself

#

Its like 20 lines

queen cloak
queen cloak
eager totem
#

oh god how did I miss that
thank you

ebon capeBOT
#

      func NewReader(b []byte) *Reader
    ```
NewReader returns a new Reader reading from b.