O'Reilly logo

Learning Go Programming by Vladimir Vivien

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The break, continue, and goto statements

Go supports a group of statements designed specifically to exit abruptly out of a running code block, such as switch and for statement, and transfer control to a different section of the code. All three statements can accept a label identifier that specifies a targeted location in the code where control is to be transferred.

The label identifier

Before diving into the core of this section, it is worthwhile to look at the label used by these statements. Declaring a label in Go requires an identifier followed by a colon, as shown in the following snippet:

DoSearch: 

Naming your label is a matter of style. However, one should follow the identifier naming guidelines covered in the previous chapter. A label must ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required