On Mon, Feb 1, 2021 at 1:38 PM Amit Lavon <amitlav...@gmail.com> wrote:

> I know it's possible to create a slice variable from an array with the [:] 
> syntax, and it points to the same underlying buffer.
> Can one do the opposite? Given a slice, create an array variable based on the 
> same buffer?

Arrays are values so they cannot share memory with other arrays/slices.

But you can create a pointer to an array that will share the memory.
Currently only using unsafe: https://play.golang.org/p/0JggbzO4ixT

-- 
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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-W4ODDYw2OwRpDpLj2%2BGVcVYyw29H_WGd9EbzEsPKEtUw%40mail.gmail.com.

Reply via email to