<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>for on Golang</title><link>https://golang.k5kc.com/tags/for/</link><description>Recent content in for on Golang</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sun, 16 Aug 2020 00:13:00 +0530</lastBuildDate><atom:link href="https://golang.k5kc.com/tags/for/index.xml" rel="self" type="application/rss+xml"/><item><title>Go loop - break and continue</title><link>https://golang.k5kc.com/2020/08/16/4.loop-break-and-continue/</link><pubDate>Sun, 16 Aug 2020 00:13:00 +0530</pubDate><guid>https://golang.k5kc.com/2020/08/16/4.loop-break-and-continue/</guid><description>Intro break will break out of a loop. It&amp;rsquo;s a way to stop looping.
continue will move on to the next iteration. Let&amp;rsquo;s see it in action.
Examples Example - break package main import &amp;#34;fmt&amp;#34; func main() { pow := make([]int, 10) for i := range pow { pow[i] = 1 &amp;lt;&amp;lt; uint(i) if pow[i] &amp;gt;= 16 { break } } fmt.Println(pow) // [1 2 4 8 16 0 0 0 0 0] } Example - continue package main import &amp;#34;fmt&amp;#34; func main() { pow := make([]int, 10) for i := range pow { if i%2 == 0 { continue } pow[i] = 1 &amp;lt;&amp;lt; uint(i) } fmt.</description></item><item><title>Go - for loop</title><link>https://golang.k5kc.com/2020/08/16/3.for-loop/</link><pubDate>Sun, 16 Aug 2020 00:12:00 +0530</pubDate><guid>https://golang.k5kc.com/2020/08/16/3.for-loop/</guid><description>Go has only one looping construct, the for loop. The basic for loop looks as it does in C or Java, except that the ( ) are gone (they are not even optional) and the { } are required. As in C or Java, you can leave the pre and post statements empty.
for init; condition; post { } Examples Example - Go loop for j := 7; j &amp;lt;= 9; j++ { fmt.</description></item></channel></rss>