zlacker

[return to "Go is still not good"]
1. porrid+vh[view] [source] 2025-08-22 12:15:12
>>ustad+(OP)
I wrote a small explainer on the typed-vs-untyped nil issue. It is one of the things that can actually bite you in production. Easy to miss it in code review.

Here's the accompanying playground: https://go.dev/play/p/Kt93xQGAiHK

If you run the code, you will see that calling read() on ControlMessage causes a panic even though there is a nil check. However, it doesn't happen for Message. See the read() implementation for Message: we need to have a nil check inside the pointer-receiver struct methods. This is the simplest solution. We have a linter for this. The ecosystem also helps, e.g protobuf generated code also has nil checks inside pointer receivers.

◧◩
2. beanju+bm[view] [source] 2025-08-22 12:42:05
>>porrid+vh
great example, that is indeed tricky
[go to top]