{"id":500,"date":"2026-09-04T09:00:00","date_gmt":"2026-09-04T03:30:00","guid":{"rendered":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/"},"modified":"2026-11-29T01:30:14","modified_gmt":"2026-11-28T20:00:14","slug":"go-control-flow-questions-part-3","status":"publish","type":"post","link":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/","title":{"rendered":"Go Control Flow Questions: If, Switch and Loops (Part 3)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">These Go control flow questions cover if, switch, for, range, labels and goto. Interviewers use them to test how you write everyday logic. We collected them from public interview lists, coding tests and forum threads. Then we grouped them by statement, so you can revise one idea at a time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This post is questions only, so answer each one in your own words first. When you need help, read <a href=\"https:\/\/smitabharat.com\/blog\/go-conditional-statements-if-else-switch\/\">Go conditional statements<\/a> and <a href=\"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/\">Go for loops<\/a>. Also, finish <a href=\"https:\/\/smitabharat.com\/blog\/go-data-types-questions-part-2\/\">Part 2 on data types<\/a> before this one.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Use These Go Control Flow Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Answer each question out loud in two or three sentences. Then write a tiny program for any question you are unsure about, because control flow is easy to test. Finally, try the scenario questions, since they show how you choose between statements.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The table below shows each section and how many questions it has.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Section<\/th><th>What it tests<\/th><th>Questions<\/th><\/tr><\/thead><tbody><tr><td>if and else<\/td><td>Conditions, init statements and errors<\/td><td>15<\/td><\/tr><tr><td>switch<\/td><td>Expression, tagless and type switches<\/td><td>17<\/td><\/tr><tr><td>for loops<\/td><td>Three forms of the single loop<\/td><td>15<\/td><\/tr><tr><td>range<\/td><td>Slices, maps, strings, channels and ints<\/td><td>16<\/td><\/tr><tr><td>break, continue, labels, goto<\/td><td>Leaving and skipping loops<\/td><td>13<\/td><\/tr><tr><td>Clean code<\/td><td>Early return and nesting<\/td><td>12<\/td><\/tr><tr><td>Code reading<\/td><td>Predict the output<\/td><td>4<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-1-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-1-1-1024x640.png\" alt=\"Go Control Flow Questions diagram showing six question areas from if and else to clean control flow\" class=\"wp-image-507\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-1-1-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-1-1-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-1-1-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-1-1-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-1-1-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Go control flow questions grouped into six areas: if and else, switch, for loops, range, labels and jumps, and clean control flow.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Go Control Flow Questions on if and else<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you answer, study <a href=\"https:\/\/smitabharat.com\/blog\/go-conditional-statements-if-else-switch\/\">Go conditional statements<\/a>. These Go control flow questions look easy, so interviewers listen for detail.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>How do you write an if statement in Go, and why are there no brackets around the condition?<\/li>\n\n\n\n<li>Why must the opening brace sit on the same line as if?<\/li>\n\n\n\n<li>What is an if statement with a short init statement?<\/li>\n\n\n\n<li>What is the scope of a variable declared in the if init statement?<\/li>\n\n\n\n<li>Can you use that variable inside the else block as well?<\/li>\n\n\n\n<li>Why does Go reject a non bool value in a condition, such as an int?<\/li>\n\n\n\n<li>How do you write the common <code>if err != nil<\/code> check, and why is it so frequent?<\/li>\n\n\n\n<li>When should you use else if instead of a switch?<\/li>\n\n\n\n<li>Is there a ternary operator in Go, so how do you write a short choice?<\/li>\n\n\n\n<li>How do you compare two strings in a condition, for example ignoring case?<\/li>\n\n\n\n<li>What does &#8220;happy path on the left&#8221; mean for Go code?<\/li>\n\n\n\n<li>Can an if statement check a map lookup and its ok value at once?<\/li>\n\n\n\n<li>How do you combine conditions safely so a nil pointer is never read?<\/li>\n\n\n\n<li>Scenario: when a function has five nested if blocks, how would you flatten it?<\/li>\n\n\n\n<li>Scenario: when an error check is missing after a file open, what bug can follow in production?<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Go Control Flow Questions on switch<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Switch in Go has several features that other languages lack. So many Go control flow questions ask how it differs from C or Java.<\/p>\n\n\n\n<ol start=\"16\" class=\"wp-block-list\">\n<li>How is a Go switch different from a switch in C or Java?<\/li>\n\n\n\n<li>Why do you not need break at the end of each case?<\/li>\n\n\n\n<li>What does fallthrough do, and when would you use it?<\/li>\n\n\n\n<li>Can fallthrough be used in the last case or in a type switch?<\/li>\n\n\n\n<li>How do you list several values in one case, such as Saturday and Sunday?<\/li>\n\n\n\n<li>What is a tagless switch, and when is it cleaner than if and else?<\/li>\n\n\n\n<li>Can a switch have an init statement like an if statement?<\/li>\n\n\n\n<li>Where can the default case appear, and does its position matter?<\/li>\n\n\n\n<li>Can case values be expressions instead of constants?<\/li>\n\n\n\n<li>What happens if two case values are the same constant?<\/li>\n\n\n\n<li>What is a type switch, and how does it differ from a value switch?<\/li>\n\n\n\n<li>How do you get the typed value inside a type switch case?<\/li>\n\n\n\n<li>What happens when you use break inside a switch inside a for loop?<\/li>\n\n\n\n<li>How would you break out of the loop instead of only the switch?<\/li>\n\n\n\n<li>Can you switch on a struct value or an interface value?<\/li>\n\n\n\n<li>Scenario: when a payment status switch misses a new status, how would you catch it early?<\/li>\n\n\n\n<li>Scenario: when a long if and else chain checks one variable, how would you refactor it?<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Go Control Flow Questions on for Loops<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before you answer, study <a href=\"https:\/\/smitabharat.com\/blog\/go-for-loops-examples\/\">Go for loops with examples<\/a>. Go has only one loop keyword, so these Go control flow questions test all its forms.<\/p>\n\n\n\n<ol start=\"33\" class=\"wp-block-list\">\n<li>Why does Go have only for, and no while or do while keyword?<\/li>\n\n\n\n<li>What are the three forms of a for loop in Go?<\/li>\n\n\n\n<li>How do you write a while style loop with for?<\/li>\n\n\n\n<li>How do you write an infinite loop, and how do you leave it?<\/li>\n\n\n\n<li>Can you leave out the init or post statement in a for loop?<\/li>\n\n\n\n<li>What is the scope of the loop variable declared in the header?<\/li>\n\n\n\n<li>How did loop variable behaviour change in Go 1.22?<\/li>\n\n\n\n<li>Why did the old behaviour cause bugs with closures and goroutines?<\/li>\n\n\n\n<li>How do you loop backwards over a slice?<\/li>\n\n\n\n<li>How do you loop with two variables, such as i going up and j going down?<\/li>\n\n\n\n<li>Can you change the loop variable inside the loop body, and is it wise?<\/li>\n\n\n\n<li>How would you write a loop that runs at most three retries?<\/li>\n\n\n\n<li>What is the cost of calling len in the loop condition?<\/li>\n\n\n\n<li>Scenario: when a loop never ends in production, what would you check first?<\/li>\n\n\n\n<li>Scenario: when old code copies the loop variable before a goroutine, is that copy still needed?<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Go Control Flow Questions on range<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Range works with many types, so interviewers ask what it returns for each. Also, the newer forms of range are a good sign that you keep up with the language.<\/p>\n\n\n\n<ol start=\"48\" class=\"wp-block-list\">\n<li>What does range return for a slice or an array?<\/li>\n\n\n\n<li>What does range return for a map, and in what order?<\/li>\n\n\n\n<li>Why is map iteration order random in Go?<\/li>\n\n\n\n<li>What does range return for a string, and why is it a rune?<\/li>\n\n\n\n<li>How do you range over a channel, and when does the loop stop?<\/li>\n\n\n\n<li>How do you range over an integer, since Go 1.22?<\/li>\n\n\n\n<li>What are range over function iterators, added in Go 1.23?<\/li>\n\n\n\n<li>Does range copy the value of each element, and why does that matter?<\/li>\n\n\n\n<li>How do you change slice elements while you range over them?<\/li>\n\n\n\n<li>What happens if you append to a slice while you range over it?<\/li>\n\n\n\n<li>Can you delete map keys while you range over the map?<\/li>\n\n\n\n<li>How do you ignore the index or the value with the blank identifier?<\/li>\n\n\n\n<li>Is range over an array different from range over a pointer to an array?<\/li>\n\n\n\n<li>How would you print map keys in sorted order?<\/li>\n\n\n\n<li>Scenario: when a test passes locally but fails in CI because of map order, how would you fix it?<\/li>\n\n\n\n<li>Scenario: when updating structs inside a range loop has no effect, what is the cause?<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Break, Continue, Labels and goto Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These statements are used less often. However, interviewers like them for tricky Go control flow questions with printed output.<\/p>\n\n\n\n<ol start=\"64\" class=\"wp-block-list\">\n<li>What is the difference between break and continue?<\/li>\n\n\n\n<li>What is a label, and how do you attach it to a loop?<\/li>\n\n\n\n<li>How does break with a label work in nested loops?<\/li>\n\n\n\n<li>How does continue with a label work in nested loops?<\/li>\n\n\n\n<li>Can a label be used with switch and select as well?<\/li>\n\n\n\n<li>Does Go have goto, and what are its rules?<\/li>\n\n\n\n<li>Why can goto not jump over a variable declaration?<\/li>\n\n\n\n<li>When, if ever, would you use goto in real code?<\/li>\n\n\n\n<li>What happens to deferred calls when you break out of a loop?<\/li>\n\n\n\n<li>How do you stop a loop early when a value is found?<\/li>\n\n\n\n<li>Can an unused label cause a compile error?<\/li>\n\n\n\n<li>Scenario: when you search a grid and want to stop at the first match, how would you exit both loops?<\/li>\n\n\n\n<li>Scenario: when a reviewer finds goto in new code, what would you suggest instead?<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Clean Control Flow Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Good Go code is easy to read from top to bottom. So these Go control flow questions test style as much as syntax.<\/p>\n\n\n\n<ol start=\"77\" class=\"wp-block-list\">\n<li>What is an early return, and why do Go developers prefer it?<\/li>\n\n\n\n<li>How deep should nesting go before you refactor?<\/li>\n\n\n\n<li>When would you replace a long switch with a map of functions?<\/li>\n\n\n\n<li>How do guard clauses make error handling easier to read?<\/li>\n\n\n\n<li>Why should a function usually do one thing, especially with loops?<\/li>\n\n\n\n<li>How do you keep a loop body short when it grows large?<\/li>\n\n\n\n<li>When is it better to return from a loop than to use a flag variable?<\/li>\n\n\n\n<li>How would you write a retry loop with a delay between attempts?<\/li>\n\n\n\n<li>What does the select statement have in common with switch?<\/li>\n\n\n\n<li>How do you test every branch of an if or switch?<\/li>\n\n\n\n<li>Scenario: when a handler mixes validation, loops and database calls, how would you split it?<\/li>\n\n\n\n<li>Scenario: when a loop must stop on a timeout, which statement would you combine with it?<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Code Reading Questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Read each program and predict the output before you run it. Then explain the reason in plain words.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\nfunc main() {\n\tswitch n := 2; n {\n\tcase 1:\n\t\tfmt.Println(\"one\")\n\tcase 2:\n\t\tfmt.Println(\"two\")\n\t\tfallthrough\n\tcase 3:\n\t\tfmt.Println(\"three\")\n\tdefault:\n\t\tfmt.Println(\"other\")\n\t}\n}<\/code><\/pre>\n\n\n\n<ol start=\"89\" class=\"wp-block-list\">\n<li>Which lines does this program print?<\/li>\n\n\n\n<li>Why does the default case not run, even though fallthrough is used?<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Here is the second program. This time, focus on labels and loop variables.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\nfunc main() {\nouter:\n\tfor i := 0; i &lt; 3; i++ {\n\t\tfor j := 0; j &lt; 3; j++ {\n\t\t\tif j == 2 {\n\t\t\t\tcontinue outer\n\t\t\t}\n\t\t\tif i == 2 {\n\t\t\t\tbreak outer\n\t\t\t}\n\t\t\tfmt.Println(i, j)\n\t\t}\n\t}\n\n\tvar funcs []func()\n\tfor i := range 3 {\n\t\tfuncs = append(funcs, func() { fmt.Print(i, \" \") })\n\t}\n\tfor _, f := range funcs {\n\t\tf()\n\t}\n\tfmt.Println()\n}<\/code><\/pre>\n\n\n\n<ol start=\"91\" class=\"wp-block-list\">\n<li>Which pairs of i and j does the first loop print?<\/li>\n\n\n\n<li>What do the saved functions print with Go 1.22 or newer, and what did older versions print?<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Revision Table for Go Control Flow<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use the table below as a final check. It lists what range gives you for each type.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Type in range<\/th><th>First value<\/th><th>Second value<\/th><\/tr><\/thead><tbody><tr><td>Slice or array<\/td><td>Index<\/td><td>Copy of the element<\/td><\/tr><tr><td>String<\/td><td>Byte index<\/td><td>Rune<\/td><\/tr><tr><td>Map<\/td><td>Key<\/td><td>Value<\/td><\/tr><tr><td>Channel<\/td><td>Received value<\/td><td>Not used<\/td><\/tr><tr><td>Integer n<\/td><td>0 to n minus 1<\/td><td>Not used<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Also, many interviewers ask when switch is better than if. The diagram below compares them.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-2-1024x640.png\" alt=\"Go Control Flow Questions diagram showing a comparison of if and else with switch\" class=\"wp-image-480\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-2-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-2-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-2-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-2-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-diagram-2-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">if and else suits a few unrelated conditions, while switch suits many cases on one value or one type, and never needs break.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These official pages describe the rules behind these questions.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/go.dev\/ref\/spec#Statements\">The Go specification: Statements<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/go.dev\/doc\/effective_go#control-structures\">Effective Go: Control structures<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/go.dev\/blog\/loopvar-preview\">Go blog: Fixing for loops in Go 1.22<\/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>These Go control flow questions cover if, switch, for, range, labels and clean code.<\/li>\n\n\n\n<li>A Go switch never falls through unless you write fallthrough.<\/li>\n\n\n\n<li>Go has one loop keyword with three forms.<\/li>\n\n\n\n<li>Loop variables are new on each iteration since Go 1.22.<\/li>\n\n\n\n<li>Range returns different values for slices, strings, maps, channels and integers.<\/li>\n\n\n\n<li>Prefer early returns over deep nesting.<\/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\">By now, you have Go control flow questions for every statement, so you can answer with clear examples. So next, we will cover functions, closures, variadic functions and defer.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next up: <a href=\"https:\/\/smitabharat.com\/blog\/go-functions-interview-questions-part-4\/\">Go functions interview questions on closures and defer (Part 4)<\/a><\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>These Go control flow questions cover if, switch, for, range, labels and goto. Interviewers use them to test how you write everyday logic. We&hellip;<\/p>\n","protected":false},"author":1,"featured_media":508,"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":[10],"tags":[96,100,95,11],"swapz_series":[],"class_list":["post-500","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-interview","tag-beginner","tag-go-control-flow","tag-go-interview-questions","tag-go-lang"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Go Control Flow Questions: If, Switch and Loops<\/title>\n<meta name=\"description\" content=\"Practise 92 Go control flow questions on if, switch, for loops, range, labels and goto, plus scenario questions from real interviews.\" \/>\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-control-flow-questions-part-3\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go Control Flow Questions: If, Switch and Loops\" \/>\n<meta property=\"og:description\" content=\"Practise 92 Go control flow questions on if, switch, for loops, range, labels and goto, plus scenario questions from real interviews.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/\" \/>\n<meta property=\"og:site_name\" content=\"Smita Bharat - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-04T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-28T20:00:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-featured-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\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=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/\"},\"author\":{\"name\":\"Smita\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"headline\":\"Go Control Flow Questions: If, Switch and Loops (Part 3)\",\"datePublished\":\"2026-09-04T03:30:00+00:00\",\"dateModified\":\"2026-11-28T20:00:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/\"},\"wordCount\":1784,\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-control-flow-questions-part-3-featured-1.png\",\"keywords\":[\"Beginner\",\"Go Control Flow\",\"Go Interview Questions\",\"Go Lang\"],\"articleSection\":[\"Interview\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/\",\"name\":\"Go Control Flow Questions: If, Switch and Loops\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-control-flow-questions-part-3-featured-1.png\",\"datePublished\":\"2026-09-04T03:30:00+00:00\",\"dateModified\":\"2026-11-28T20:00:14+00:00\",\"description\":\"Practise 92 Go control flow questions on if, switch, for loops, range, labels and goto, plus scenario questions from real interviews.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/#primaryimage\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-control-flow-questions-part-3-featured-1.png\",\"contentUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-control-flow-questions-part-3-featured-1.png\",\"width\":2400,\"height\":1260,\"caption\":\"Go Control Flow Questions featured image: if, switch and range cards\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-control-flow-questions-part-3\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go Control Flow Questions: If, Switch and Loops (Part 3)\"}]},{\"@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 Control Flow Questions: If, Switch and Loops","description":"Practise 92 Go control flow questions on if, switch, for loops, range, labels and goto, plus scenario questions from real interviews.","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-control-flow-questions-part-3\/","og_locale":"en_US","og_type":"article","og_title":"Go Control Flow Questions: If, Switch and Loops","og_description":"Practise 92 Go control flow questions on if, switch, for loops, range, labels and goto, plus scenario questions from real interviews.","og_url":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/","og_site_name":"Smita Bharat - Blog","article_published_time":"2026-09-04T03:30:00+00:00","article_modified_time":"2026-11-28T20:00:14+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-featured-1.png","type":"image\/png"}],"author":"Smita","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Smita","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/#article","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/"},"author":{"name":"Smita","@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"headline":"Go Control Flow Questions: If, Switch and Loops (Part 3)","datePublished":"2026-09-04T03:30:00+00:00","dateModified":"2026-11-28T20:00:14+00:00","mainEntityOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/"},"wordCount":1784,"publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-featured-1.png","keywords":["Beginner","Go Control Flow","Go Interview Questions","Go Lang"],"articleSection":["Interview"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/","url":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/","name":"Go Control Flow Questions: If, Switch and Loops","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/#primaryimage"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-featured-1.png","datePublished":"2026-09-04T03:30:00+00:00","dateModified":"2026-11-28T20:00:14+00:00","description":"Practise 92 Go control flow questions on if, switch, for loops, range, labels and goto, plus scenario questions from real interviews.","breadcrumb":{"@id":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/#primaryimage","url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-featured-1.png","contentUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-control-flow-questions-part-3-featured-1.png","width":2400,"height":1260,"caption":"Go Control Flow Questions featured image: if, switch and range cards"},{"@type":"BreadcrumbList","@id":"https:\/\/smitabharat.com\/blog\/go-control-flow-questions-part-3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smitabharat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go Control Flow Questions: If, Switch and Loops (Part 3)"}]},{"@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\/500","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=500"}],"version-history":[{"count":1,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/500\/revisions"}],"predecessor-version":[{"id":522,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/500\/revisions\/522"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media\/508"}],"wp:attachment":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media?parent=500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/categories?post=500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/tags?post=500"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}