I've slightly modified a very simple Switch example from "A Tour of Go" website:
package main
import (
"fmt"
"time"
)
func main() {
day := "Wednesday"
fmt.Printf("When's %s?\n", day)
today := time.Now().Weekday()
switch time.Wednesday {
case today + 0:
fmt.Println("Today.")
case today + 1:
fmt.Println("Tomorrow.")
case today + 2:
fmt.Println("In two days.")
default:
fmt.Println("Too far away.")
}
}
Instead of time.Wednesday
I would like to use the value of day
to fetch the time.Weekday
.
In Python/JS it would be time[day]
.
How does one do this in Go ?