Followed the do..while pattern recommended here:
for {
work()
if !condition {
break
}
}
Below code is implementing do..while(condition) using for loop:
var r *s
var err error
counter := 0
for { // do..while(specificerror && < MAX && trigger_not_initiated)
r, err = f()
counter = counter + 1
if !(err != nil &&
strings.Contains(err.Error(), "specificerror") &&
counter < MAX &&
!IsTriggerInitiated()) {
break
}
}
But review team suggests to make if condition more readable by removing negation in negation(condition) in if statement
How to remove negation in negation(condition) for if statement?
Exactly as suggested ("use
||")is equivalent to
For more information, see De Morgan's laws.