3 ms·
My big complaint with Golang is the way they (don't) handle nulls. Golang treats null as a memory initialization problem, while ignoring its semantic use. You
by spiffytech 4y ago
My big complaint with Golang is the way they (don't) handle nulls.
Golang treats null as a memory initialization problem, while ignoring its semantic use.
You still encounter nulls when interacting with external systems, and Golang has inconsistent ways of handling them. From memory (it's been a while):
- Nullable DB columns return a struct with the value, and a boolean for whether the value is actually the value, or a placeholder for null
- Requesting a non-existent query parameter from an inbound HTTP request returns an empty string. That's "fun" to debug.
- Decoding a JSON object with a null value omits the key+value completely. There's no way to tell the key was ever present. This is a problem when you don't control the originator of the JSON.
- I think maybe sometimes null pointers are used?