Hacker News new | ask | show | jobs
by Jabbles 3348 days ago
Because go's garbage collector can and will move and copy memory as it sees fit.

Is there more to this than the fact that the Go language specification doesn't forbid it? Have you seen it happen?

1 comments

There's a few things here.

First, the fact that go's language specification allows for this should be enough to stop you right there. Even if today it doesn't move memory around, an update very well could. This library is supposed to be used for cryptographic secrets; "it works by accident for now, probably" is not even close to the kind of situation you should be designing an API around. At any point, without serious warning, an update to the golang runtime can render these protections useless.

There are situations today where go will move data on the stack. I am unsure if it will move heap allocations, but when the garbage collector adds compaction support this will absolutely be the case.