Let's say I have the following function:
func foo(bar []int) {
bar[0] = 456
}
I want to create an []int
with one element that references a
, such that when I:
var a int = 10
// mySlice := ... crazy hackery?
foo(mySlice)
The value of a
will be 456.
I know this is crazy and stupid and not at all the right thing to do. I'm not looking for the "correct" way. The function prototype for foo
must remain the same.
I can guarantee that while the underlying int
will change, the slice that points to it is immutable.
The reason for the strange requirement is because this is for the c2go project.