You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Having to specify every covered struct in a global configuration file isn't ideal for reasons such as build incrementalism. I suggest also supporting an approach similar to the one used in nishanths/exhaustive, except at the struct level.
//exhaustruct:enforce
type Params struct {
RequiredInt int
RequiredString string
}
type Data struct {
OptionalInt int
OptionalString string
}
Unlike in that other analyzer, it probably makes sense to always enforce presence at every site of struct initialization by default if the struct is configured to require parameters. This is consistent with e.g. how most languages deal with named, required parameters to function calls.
A global configuration flag -explicit-exhaustive-struct with default value false would be required to maintain backwards compatibility (in the sense of ensuring previously failed builds continue to fail).
The text was updated successfully, but these errors were encountered:
@xobotyi Do you have any thoughts on the merits of this suggestion? It is likely to cause a performance hit due to multi-pass, but that can be gated by a flag. The added cost is likely worth it for many organizations compared to the cache invalidation cost of editing the golangci-lint config upon every new struct to be allowlisted.
Having to specify every covered struct in a global configuration file isn't ideal for reasons such as build incrementalism. I suggest also supporting an approach similar to the one used in nishanths/exhaustive, except at the struct level.
Unlike in that other analyzer, it probably makes sense to always enforce presence at every site of struct initialization by default if the struct is configured to require parameters. This is consistent with e.g. how most languages deal with named, required parameters to function calls.
A global configuration flag
-explicit-exhaustive-struct
with default valuefalse
would be required to maintain backwards compatibility (in the sense of ensuring previously failed builds continue to fail).The text was updated successfully, but these errors were encountered: