goto

Go does have a goto statement, but it is very rarely used. Create a label with a name and a colon, then go to it using the goto keyword. Here is a basic example:

package mainimport "fmt"func main() {   goto customLabel   // Will never get executed because   // the goto statement will jump right   // past this line   fmt.Println("Hello")   customLabel:   fmt.Println("World")} 

Get Security with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.