Poorly formed nilness guards can be fatal as they might lead to unwanted panic
because
of nil
pointer dereferences. Depending on the binary expression, the logic might not
work as expected because of the poorly formed guards. In a binary expression, it is crucial
to creating good nilness guards so that executing the other operand in the expression is
safe.
if cmd == nil && cmd.Execute() == 0 {
// do something
}
if cmd != nil || cmd.Execute() == 0 {
// do something
}
if cmd != nil && cmd.Execute() == 0 {
// do something
}
if cmd == nil || cmd.Execute() == 0 {
// do something
}