golang / tour

[mirror] A Tour of Go
BSD 3-Clause "New" or "Revised" License
1.54k stars 521 forks source link

tour: Day of Week - Switch case exercise #1407

Open santiagofern opened 2 years ago

santiagofern commented 2 years ago

Context: https://go.dev/tour/flowcontrol/10

Change the title above to describe your issue and add your feedback here, including code if necessary

As a user of this training, I would expect this:

package main

import (
    "fmt"
    "time"
)

func main() {
    fmt.Println("When's Saturday?")
    today := time.Now().Weekday()
    switch time.Saturday {
    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.")
    }
}

To print out when saturday is which reached the default case eventhough it is Friday.

pashchenkoromak commented 1 year ago

As pointed in https://github.com/golang/tour/issues/1249 , there is, in description of excersice: Note: Time in the Go playground always appears to start at 2009-11-10 23:00:00 UTC, a value whose significance is left as an exercise for the reader.