3 ms·
> In Go, unsafe code is only possible by importing unsafe or C. of course, this is completely wrong, for anyone reading this. that is simply not how systems wo
by heywhatupboys 4y ago
> In Go, unsafe code is only possible by importing unsafe or C.
of course, this is completely wrong, for anyone reading this. that is simply not how systems work
- the-smug-one 4y agoOK, do you intend to say why?
- thiht 4y agoHow do "systems" (whatever you're talking about) work then?
- mikedelago 4y agoI think they are speaking without the context that "unsafe = lack of memory safety" and with the context that "unsafe = you can still drop the database"
- jchw 4y agoNote that "unsafe" in this context refers to memory safety. I am not making the claim that Go code which does not import unsafe or C is free of bugs; however, if you don't import unsafe or C anywhere in your application or dependencies (sans the stdlib) then it is memory safe (assuming no compiler or OS bugs compromise that guarantee.) That's just how Go is specified. The unsafe package in Go provides unsafe.Pointer, which allows you to convert between a pointer and integral type, essentially allowing you to make pointers of any type to any address, giving up type safety. Without it, Go pointers are safe, because the GC will never free memory that has live pointers, and you can't do math on Go pointers.