go switch case
switch time.Now().Weekday() {
case time.Saturday, time.Sunday:
fmt.Println("It's the weekend")
default:
fmt.Println("It's a weekday")
}
go switch case
switch time.Now().Weekday() {
case time.Saturday, time.Sunday:
fmt.Println("It's the weekend")
default:
fmt.Println("It's a weekday")
}
golang switch
package main
import (
"fmt"
"time"
)
func main() {
isDay := time.Sunday
switch isDay {
case time.Monday:
fmt.Println("day is monday")
case time.Sunday:
fmt.Println("day is sunday")
case time.Tuesday:
fmt.Println("day is tuesday")
case time.Wednesday:
fmt.Println("day is wenesday")
case time.Thursday:
fmt.Println("day is thursday")
case time.Friday:
fmt.Println("day is friday")
case time.Saturday:
fmt.Println("day is saturday")
default:
fmt.Println("day is not exist")
}
// multiple check
switch browser := "firefox"; browser {
case "chrome", "opera", "firefox":
fmt.Println("my browser is", browser)
default:
fmt.Println("browser is not define")
}
// iflese style
var point = 6
switch {
case point == 8:
fmt.Println("perfect")
case (point < 8) && (point > 3):
fmt.Println("awesome")
default:
{
fmt.Println("not bad")
fmt.Println("you need to learn more")
}
}
}
case in golang
i := 2
fmt.Print("Write ", i, " as ")
switch i {
case 1:
fmt.Println("one")
case 2:
fmt.Println("two")
case 3:
fmt.Println("three")
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us