On Thu, Feb 4, 2021 at 10:32 PM Steve Roth <[email protected]> wrote:
>
> How can I implement a writeByte function, against an unknown io.Writer
> implementation, that doesn't allocate heap memory?
>
The only way I'm aware of achieving this is proving to the compiler that
buf is safe to be kept by w by moving buf to the package block.
var buf [1]byte
func writeByte(b byte) {
buf[0] = b
_, err = w.Write(buf[:])
}
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/CAFEfeLzBaQSyQBpSqGa4YE8n8T_VPooRyz5KBLV%2B4jWitRqR%3Dg%40mail.gmail.com.