{"id":136,"date":"2026-03-31T09:00:00","date_gmt":"2026-03-31T03:30:00","guid":{"rendered":"https:\/\/smitabharat.com\/blog\/?p=136"},"modified":"2026-10-10T21:20:36","modified_gmt":"2026-10-10T15:50:36","slug":"go-for-loops-examples","status":"publish","type":"post","link":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/","title":{"rendered":"Go For Loops Explained with Simple Examples"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Go for loops let your program repeat a task without writing the same code again and again. In this post, you will learn every loop style Go offers. Each one comes with a short example that you can run yourself.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Loops build on the last lesson, because every loop checks a condition before each round. So if true and false checks still feel new, first read <a href=\"https:\/\/smitabharat.com\/blog\/go-conditional-statements-if-else-switch\/\">if, else and switch in Go<\/a>. You will also use <code>&lt;=<\/code>, <code>++<\/code> and <code>+=<\/code> from <a href=\"https:\/\/smitabharat.com\/blog\/go-operators-examples\/\">operators in Go with simple examples<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Are Go For Loops?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A loop runs the same block of code many times. Each single run is called an iteration. Think of a teacher calling roll: she reads one name, then the next, and stops after the last student.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Many languages have for, while and do while loops. However, Go keeps things simple. It has only one loop keyword, <code>for<\/code>, and you shape it in different ways. As a result, Go for loops cover every repeat job you will ever need.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Three-Part Loop<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>for i := 1; i &lt;= 5; i++ {\n\tfmt.Println(\"Count:\", i)\n}\n\/\/ Count: 1\n\/\/ Count: 2\n\/\/ Count: 3\n\/\/ Count: 4\n\/\/ Count: 5<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Among all Go for loops, this is the one you will see most often. It has three parts separated by semicolons, and like if, it needs no brackets around them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How Each Part Works<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Init<\/strong> (<code>i := 1<\/code>) runs once, before the loop starts.<\/li>\n\n\n\n<li><strong>Condition<\/strong> (<code>i &lt;= 5<\/code>) is checked before every round.<\/li>\n\n\n\n<li><strong>Body<\/strong> is the code inside the braces, and it runs while the condition is true.<\/li>\n\n\n\n<li><strong>Post<\/strong> (<code>i++<\/code>) runs after each round, and then Go checks the condition again.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-diagram-1024x640.png\" alt=\"Go For Loops diagram showing the init, condition, body and post steps of a three-part loop\" class=\"wp-image-138\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-diagram-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-diagram-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-diagram-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-diagram.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Init runs once, then condition, body and post repeat until the condition becomes false.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Go For Loops Without a Counter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Sometimes you do not know how many rounds you need. In that case, you can drop the init and post parts and keep only the condition.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The While-Style Loop<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>n := 1\nfor n &lt; 100 {\n\tn = n * 2\n}\nfmt.Println(n) \/\/ 128<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This loop keeps doubling <code>n<\/code> while it stays below 100. In other languages, you would call this a while loop. Go simply uses <code>for<\/code> with one condition.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Infinite Loop with break<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>tries := 0\nfor {\n\ttries++\n\tif tries == 3 {\n\t\tfmt.Println(\"Got it on try\", tries)\n\t\tbreak\n\t}\n}\n\/\/ Got it on try 3<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A <code>for<\/code> with nothing after it runs forever. So you must stop it yourself with <code>break<\/code>, which exits the loop at once. Servers often use this pattern to keep listening for new requests.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Skipping Steps in Go For Loops with continue<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>for i := 1; i &lt;= 6; i++ {\n\tif i%2 == 0 {\n\t\tcontinue\n\t}\n\tfmt.Print(i, \" \")\n}\n\/\/ 1 3 5<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>continue<\/code> keyword skips the rest of the current round and jumps to the next one. Here it skips every even number, so only odd numbers print. In short, break stops the loop, while continue only skips one step.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Looping with range in Go For Loops<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>range<\/code> keyword walks through a collection one item at a time. Think of it as a cashier scanning each product in your basket.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Range over a Slice<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>fruits := &#91;]string{\"apple\", \"mango\", \"banana\"}\nfor i, fruit := range fruits {\n\tfmt.Println(i, fruit)\n}\n\/\/ 0 apple\n\/\/ 1 mango\n\/\/ 2 banana\n\ntotal := 0\nfor _, price := range &#91;]int{40, 25, 35} {\n\ttotal += price\n}\nfmt.Println(\"Total:\", total) \/\/ Total: 100<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Range gives you two values: the position, called the index, and the item itself. If you do not need the index, write an underscore <code>_<\/code> instead. The underscore tells Go to throw that value away.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Range over a Number or a String<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>for i := range 3 {\n\tfmt.Print(i, \" \")\n}\n\/\/ 0 1 2\n\nfor i, ch := range \"Go!\" {\n\tfmt.Println(i, string(ch))\n}\n\/\/ 0 G\n\/\/ 1 o\n\/\/ 2 !<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Since Go 1.22, <code>range 3<\/code> counts from 0 up to 2. Also, range over a string gives you each character, which Go calls a rune.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Breaking Out of Nested Go For Loops<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>outer:\n\tfor i := 1; i &lt;= 3; i++ {\n\t\tfor j := 1; j &lt;= 3; j++ {\n\t\t\tif i*j == 4 {\n\t\t\t\tbreak outer\n\t\t\t}\n\t\t\tfmt.Println(i, j)\n\t\t}\n\t}\n\/\/ 1 1, 1 2, 1 3, 2 1 (each on its own line)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A plain break exits only the inner loop. However, a label like <code>outer:<\/code> lets you exit both loops in one step. Use labels sparingly, since they can make code harder to follow.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes with Go For Loops<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Error you see<\/th><th>Why it happens<\/th><th>How to fix it<\/th><\/tr><\/thead><tbody><tr><td>declared and not used: i<\/td><td>The range index is never read.<\/td><td>Replace i with _.<\/td><\/tr><tr><td>panic: runtime error: index out of range [3] with length 3<\/td><td>The loop used i &lt;= len(n).<\/td><td>Use i &lt; len(n) or range.<\/td><\/tr><tr><td>Program never stops<\/td><td>The condition never turns false.<\/td><td>Update the counter or add break.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The second mistake is called an off-by-one error. Positions start at 0, so the last valid index is always one less than the length. Loop questions like this also come up often in my <a href=\"https:\/\/smitabharat.com\/blog\/go-lang-interview-questions-and-answers\/\">Go interview questions and answers<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These pages come straight from the Go team, so they are always accurate and up to date.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/go.dev\/tour\/flowcontrol\/1\">A Tour of Go: For<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/go.dev\/ref\/spec#For_statements\">Go spec: For statements<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/go.dev\/doc\/effective_go#for\">Effective Go: For<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go for loops are the only loop in Go, and you shape them in different ways.<\/li>\n\n\n\n<li>The three-part loop has init, condition and post.<\/li>\n\n\n\n<li>A loop with only a condition works like a while loop.<\/li>\n\n\n\n<li>Use break to stop and continue to skip one round.<\/li>\n\n\n\n<li>Range walks through slices, strings and numbers, giving index and value.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now you can repeat work with loops. Next, we will package that work into reusable blocks called functions, so you can call the same logic anywhere.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Coming soon: Go Functions Explained for Beginners<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go for loops let your program repeat a task without writing the same code again and again. In this post, you will learn every&hellip;<\/p>\n","protected":false},"author":1,"featured_media":192,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[15],"tags":[27,11,23,21],"swapz_series":[],"class_list":["post-136","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go-lang","tag-go-for-loops","tag-go-lang","tag-go-tutorial","tag-golang-basics"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Go For Loops Explained with Simple Examples<\/title>\n<meta name=\"description\" content=\"Learn Go for loops with simple examples: the three-part loop, while-style loops, break, continue, range and the mistakes beginners make.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go For Loops Explained with Simple Examples\" \/>\n<meta property=\"og:description\" content=\"Learn Go for loops with simple examples: the three-part loop, while-style loops, break, continue, range and the mistakes beginners make.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"Smita Bharat - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-03-31T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-10-10T15:50:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-featured-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Smita\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Smita\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/\"},\"author\":{\"name\":\"Smita\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"headline\":\"Go For Loops Explained with Simple Examples\",\"datePublished\":\"2026-03-31T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:50:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/\"},\"wordCount\":768,\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-for-loops-examples-featured-1.png\",\"keywords\":[\"Go For Loops\",\"Go Lang\",\"Go Tutorial\",\"Golang Basics\"],\"articleSection\":[\"Go Lang\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/\",\"name\":\"Go For Loops Explained with Simple Examples\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-for-loops-examples-featured-1.png\",\"datePublished\":\"2026-03-31T03:30:00+00:00\",\"dateModified\":\"2026-10-10T15:50:36+00:00\",\"description\":\"Learn Go for loops with simple examples: the three-part loop, while-style loops, break, continue, range and the mistakes beginners make.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/#primaryimage\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-for-loops-examples-featured-1.png\",\"contentUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-for-loops-examples-featured-1.png\",\"width\":1200,\"height\":630,\"caption\":\"Go For Loops featured image: cards showing the three-part loop, range, break and continue\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-for-loops-examples\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go For Loops Explained with Simple Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\",\"name\":\"Smita Bharat Blog\",\"description\":\"Golang &amp; Backend Development Tutorials and Interview Questions\",\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"alternateName\":\"Smita Bharat\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\",\"name\":\"Smita\",\"logo\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/smitabharat.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go For Loops Explained with Simple Examples","description":"Learn Go for loops with simple examples: the three-part loop, while-style loops, break, continue, range and the mistakes beginners make.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/","og_locale":"en_US","og_type":"article","og_title":"Go For Loops Explained with Simple Examples","og_description":"Learn Go for loops with simple examples: the three-part loop, while-style loops, break, continue, range and the mistakes beginners make.","og_url":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/","og_site_name":"Smita Bharat - Blog","article_published_time":"2026-03-31T03:30:00+00:00","article_modified_time":"2026-10-10T15:50:36+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-featured-1.png","type":"image\/png"}],"author":"Smita","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Smita","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/#article","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/"},"author":{"name":"Smita","@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"headline":"Go For Loops Explained with Simple Examples","datePublished":"2026-03-31T03:30:00+00:00","dateModified":"2026-10-10T15:50:36+00:00","mainEntityOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/"},"wordCount":768,"publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-featured-1.png","keywords":["Go For Loops","Go Lang","Go Tutorial","Golang Basics"],"articleSection":["Go Lang"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/","url":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/","name":"Go For Loops Explained with Simple Examples","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/#primaryimage"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-featured-1.png","datePublished":"2026-03-31T03:30:00+00:00","dateModified":"2026-10-10T15:50:36+00:00","description":"Learn Go for loops with simple examples: the three-part loop, while-style loops, break, continue, range and the mistakes beginners make.","breadcrumb":{"@id":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/#primaryimage","url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-featured-1.png","contentUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-for-loops-examples-featured-1.png","width":1200,"height":630,"caption":"Go For Loops featured image: cards showing the three-part loop, range, break and continue"},{"@type":"BreadcrumbList","@id":"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smitabharat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go For Loops Explained with Simple Examples"}]},{"@type":"WebSite","@id":"https:\/\/smitabharat.com\/blog\/#website","url":"https:\/\/smitabharat.com\/blog\/","name":"Smita Bharat Blog","description":"Golang &amp; Backend Development Tutorials and Interview Questions","publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"alternateName":"Smita Bharat","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smitabharat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339","name":"Smita","logo":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/smitabharat.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/comments?post=136"}],"version-history":[{"count":1,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/136\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/136\/revisions\/139"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media\/192"}],"wp:attachment":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media?parent=136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/categories?post=136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/tags?post=136"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}