golang / tour

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

tour: Server date is wrong #1543

Closed Leonardo-Boss closed 1 year ago

Leonardo-Boss commented 1 year ago

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

The server date is two days late so I doubt it's a time zone issue

evaluating this code in the server

package main

import (
    "fmt"
    "time"
)

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

results in:

When's Saturday?
Tuesday
Too far away.

image

running the same code on my local machine results in the correct date

When's Saturday?
Thursday
In two days.
Leonardo-Boss commented 1 year ago

closing because it's a duplicate of https://github.com/golang/tour/issues/1339