Go (programming language) - Go Loops - Go goto Statement - Go (programming language)

What is a goto statement in Go programming language?

A goto statement facilitates an unconditional jump from the goto to a labeled statement in the same function.

It is to be noted in any programming language, goto statement is not encouraged to use as tracing of the control flow becomes difficult, and the program becomes hard to understand and modify.

Syntax

The syntax for a goto statement in Go is as follows:

Here label can be any plain text except Go keyword and it can be set anywhere in the Go program above or below to goto statement.

Flow Diagram

Go goto statement

Example

When the above code is compiled and executed, the result produced appears as -

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Go (programming language) Topics