The analyzer has detected a code fragment that most likely contains a typo. A chain of similar structure member comparisons contains an expression that differs from the others. It compares members with different names, while the rest of the chain compares members with the same name.
The example:
func foo(a TestStruct, b TestStruct) interface{} {
if a.x == b.x && a.y == b.y && a.z == b.y {
....
}
}
In this case, the a.z == b.y expression differs from the other elements in the chain. The error most likely occurred due to a typo made while editing the copied text.
The fixed code:
func foo(a TestStruct, b TestStruct) interface{} {
if a.x == b.x && a.y == b.y && a.z == b.z {
....
}
}
The analyzer issues a warning whenever the comparison chain has more than two expressions.
This diagnostic is classified as:
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders:
Take
a chance!