On Thu, Jun 17, 2021 at 9:43 AM Joshua <joshua.oconno...@gmail.com> wrote:

> 1) I'm modelling a data type which has a field which may or may not be
>    there, would most Gophers reach for a pointer here, and use `nil' to
>    represent a missing value?

That's the usual approach seen in the wild and IMO often the wrong one.

Unless the size of the field's type is big, I'd suggest just a plain
field and a boolean value that represents the "present/valid"
information.

Less GC pressure, improved cache locality.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAA40n-XGP2edWe1b13kpE4PhdFdCsJWGk79z8ngEpj19ycwmxQ%40mail.gmail.com.

Reply via email to