3 ms·
There's a library called "unsafe" explicitely for this. I think it's reasonable to expect people to generally not use it, though. http://golang.org/pkg/unsafe
by Symmetry 14y ago
There's a library called "unsafe" explicitely for this. I think it's reasonable to expect people to generally not use it, though.
http://golang.org/pkg/unsafe/ http://golang.org/pkg/unsafe/
- eurleif 14y agoAs far as I know, it can only create a pointer of type A that actually points to a value of type B, not reference unallocated/deallocated memory. Nullable<T> could do that too if the language allowed it.
- lagom 14y agoIt's definitely possible to access unallocated memory e.g., // p points to address 1000 p := (*int)(unsafe.Pointer(uintptr(1000))) Of course, this is why use of the unsafe package is heavily discouraged.