First at all, is there is way to pass a big struct or array (not slice) while keeping the memory on the stack and preventing the memory to be copied in the heap?
Example:func main() {// allocated in stack (good!)type BigStruct { a string; data [64]byte }var identifier BigStruct// passing as value (does it copy the value?)// it should not, since the value is inmutable, a COW optimization could be applieda := sum(identifier)
// passing as pointer (is it copied to the heap? --> bad)// also, semantically is confusing, since it looks like that function has side-effects when it doesn't.a = sumPtr(&identifier)}
func sum(a BigStruct) int {
var sum intfor i:=0; i < 16; i++ {sum += a.data[i]}return sum}func sumPtr(a *BigStruct) int {var sum intfor i:=0; i < 16; i++ {sum += a.data[i]}return sum}is there plans to add copy-on-write optimization?