Go: do-while loop

To emulate the C/Java do-while loop

do {
        work();
} while (condition);

use one of the following equivalent Go alternatives:

for ok := true; ok; ok = condition {
        work()
}
for {
        work()
        if !condition {
                break
        }
}

Comments

Be the first to comment!