Go uses the for
loop for all looping purposes — no while
or do-while
. It's clean, powerful, and flexible.
for
.while
by omitting init and post statements.break
exits the loop early, and continue
skips to the next iteration.for {}
to create an infinite loop — handy for servers and background workers.