3 ms·
Minor nit... > It is not possible to create a Go program where two variables share the same storage location in memory. It is possible to do so, because the e
by pebers 9y ago
Minor nit...
> It is not possible to create a Go program where two variables share the same storage location in memory.
It is possible to do so, because the empty struct occupies no space. For example:
s := []struct{}{
struct{}{},
struct{}{},
}
fmt.Printf("%p %p\n", &s[0], &s[1])
> 0x176f44 0x176f44
But that's kind of a fringe case, and I suppose one might argue that the two variables occupy no space so in a sense they don't share that space. Either way it doesn't detract from the original point of the post :)