#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Control Flow

Understanding Control Flow: If-Else, Switch, and Loops in Go

if-else in Go

age := 20
if age >= 18 {
    fmt.Println("Adult")
} else {
    fmt.Println("Minor")
}

switch Statement

day := 3
switch day {
case 1:
    fmt.Println("Monday")
case 2:
    fmt.Println("Tuesday")
default:
    fmt.Println("Other day")
}

Unlike C or Java, Go's switch doesn't require a break — it doesn't fall through to the next case by default.

Loops in Go

Go has only one looping construct: for, which can be used in multiple ways.

for i := 0; i < 5; i++ {
    fmt.Println(i)
}

// while-style loop
i := 0
for i < 5 {
    fmt.Println(i)
    i++
}

// infinite loop
for {
    break
}

Ready to master real-world Go skills?

Learn Go hands-on with mentor-led, live sessions.

Explore Course