3 ms·
The problem isn't that users are accidentally using it. People are using it intentionally. The problem is that some of the config fields are mandatory, and so
by everforward 4y ago
The problem isn't that users are accidentally using it. People are using it intentionally.
The problem is that some of the config fields are mandatory, and some are optional, but the developer can't tell whether the fields were intentionally set to a weird value or just not specified, and users can't tell which fields need to be set to not have strange behavior.
You would need to add a Verified field for each config option so you can tell whether users set it or it's a default.
Alternately, you can use pointers, but that gets clunky because you can't do
conf := sarama.Connect(Config{ ClientID: &"foo"})
You have to declare a variable above, and then reference the var.
Zero values are sometimes valid config options, but not what most people actually want to do. Structs cause issues because there's no way to specify just a couple of fields in the struct; the rest will get zero values.