3 ms·
Why is null in Go unsafe?
by ychen306 8y ago
Why is null in Go unsafe?
- seandougall 8y agoPresumably because there’s no language-level way to guarantee a pointer to be non-nil at compile time, combined with nil dereferencing being a crash. Not unsafe in the security sense, but definitely unsafe in the “can I count on my program to run” sense.
- Freaky 8y agores, err := http.Get("wcpgw") defer res.Body.Close() ... panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x5ed9af]