
[Golang] How To Loop Data Using Golang
Looping in programming languages is the process of repeating the execution of a block of code until the desired conditions are met.
If the desired conditions are not met, the looping process will be terminated using a break statement, etc.
In the GO programming language, the looping process uses a for statement. The following is the use of for in the GO language.
- Using FOR without additional conditions and statements

The code above is an example of using for without conditions and additional statements by displaying numbers 1 to 5.

2. Using FOR with break statement

The code above is an example of using for with the addition of a break statement. If the number is more than 3, the looping process will be stopped using the break statement.

3. Using FOR with continue statement

The code above is an example of using for with the addition of a continue statement. If the mod 2 number is 0 then the looping process will be skipped and continue to the next process.

4. Using FOR Range

The code above is an example of using for range. In the go programming language, the foreach statement is replaced by a for range. Where the data will be repeated based on the amount of data.

5. Using FOR Nested

The code above is an example of for nested with data looping starting from the smallest.


The code above is an example of for nested with data looping starting from the largest.

Finally, we already know the looping process in the go programming language. So that later we can apply it to the API or system that we will create.