Let’s continue… haha
See what I did there?
Bleh, okay.
Continue statements
A “continue” statement begins the next iteration of the innermost enclosing “for” loop by advancing control to the end of the loop block. The “for” loop must be within the same function.
ContinueStmt = "continue" [ Label ] .
There’s not a lot necessary to say here. continue works very much like break. The scoping rules are essentially the same.
The only differences:
continueonly works in aforloop. It doesn’t apply toswitchorselectstatements.- Because it doesn’t apply to
switchorselectstatements, you only need to use a label with nestedforloops. - Rather than terminating the loop, it jumps to the next iteration.
If there is a label, it must be that of an enclosing “for” statement, and that is the one whose execution advances.
RowLoop: for y, row := range rows { for x, data := range row { if data == endOfRow { continue RowLoop } row[x] = data + bias(x, y) } }
Quotes from The Go Programming Language Specification Language version go1.22 (Feb 6, 2024)