This is not forwards-compatible, since any missing fields will be initialized to their zero-values. If a future field with a non-zero default is introduced, e.g. DontCrash: true, then all old code that uses custom options will break.
I believe the best practice in the Go community is to either have structs that default to their zero values, or use a constructor. Litter currently does neither, as the default config is:
The recommended way to configure an individual Litter instance is via an
Options
struct literal, e.g:This is not forwards-compatible, since any missing fields will be initialized to their zero-values. If a future field with a non-zero default is introduced, e.g.
DontCrash: true
, then all old code that uses custom options will break.I believe the best practice in the Go community is to either have structs that default to their zero values, or use a constructor. Litter currently does neither, as the default config is:
Not sure what the best approach would be, this is just an observation.