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
By default, the linter only checks exported (uppercase) fields in Equals()
methods. This leaves structs with private fields completely unchecked.
Add a new checkUnexported config option (default: false) that enables
linting of unexported fields as well. This is useful for internal types
like policy IR structs that use lowercase field names."
Signed-off-by: timflannagan <timflannagan@gmail.com>
The analyzer ensures that all exported fields of a struct are used in its `Equals()` method. If a field is not compared, it could lead to incorrect equality results.
65
+
By default, the analyzer ensures that all exported fields of a struct are used in its `Equals()` method. If a field is not compared, it could lead to incorrect equality results.
66
+
67
+
When `checkUnexported: true` is enabled, unexported (lowercase) fields are also checked. This is useful for structs with private fields that should still participate in equality comparisons.
64
68
65
69
```go
66
70
typeMyStructstruct {
@@ -116,6 +120,7 @@ type MyStruct struct {
116
120
| Option | Type | Default | Description |
117
121
|--------|------|---------|-------------|
118
122
|`deepEqual`| bool |`false`| Enable detection of `reflect.DeepEqual` usage in `Equals()` methods |
123
+
|`checkUnexported`| bool |`false`| Check unexported (lowercase) fields in addition to exported fields |
0 commit comments