Getting started with Go — Switch Statements

switch condition {case answer:   //do somethingdefault:}
switch time.Now().Day() {case 0:fmt.Println("Monday")case 1:fmt.Println("Tuesday")case 2:fmt.Println("Wednesday")case 3:fmt.Println("Thursday")case 4:fmt.Println("Friday")case 5, 6:fmt.Println("Weekend!!")}
answer := 15switch {case answer%5 == 0:fmt.Println("It is divisible by 5")fallthroughcase answer%3 == 0:fmt.Println("It is divisible by 3")default:fmt.Println("The answer is neither divisible by 5 or 3")}
It is divisible by 5
It is divisible by 3




Learning, and posting my findings!

Love podcasts or audiobooks? Learn on the go with our new app.

Future Aspects of Laravel Mobile App Development

Kubernetes Operators and Helm — It takes Two to Tango

Python vs C++

Microservices: Architectural building blocks and trends

Highlight Important Details with Custom Styling for Routing Sections

The Second Round of Dmail Pre-sale is Coming!

Python “tricks” Demystified

Understanding Garbage Collection and Android Context

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matthew Boyd

Matthew Boyd

Learning, and posting my findings!

More from Medium

Day 1 Go Training — Basics of GoLang

Why should you learn Golang?

Go Language — Part 1(What is Go Language and Setup the Environment)?

The Proper Way To Start A Node Project