4 ms·
FWIW, I never had that problem, but I also tend to use constructors for my structs.
by arendtio 7y ago
FWIW, I never had that problem, but I also tend to use constructors for my structs.
- whateveracct 7y agoWhen you use constructors you lose named arguments though. One use-case where this is really painful: I like to encode sum types in Go using an interface with a private dummy method + structs that implement that. I then have a function "match" that takes one function per struct. It's nice to be able to pass these functions as a record since it gets ugly, but due to Go allowing omitted functions to be nil, if I add a case to the sum, I open myself up to NPEs everywhere. If Go had a warning for missing struct fields, it would tell me all the places I'd need to handle a new case.