Closed gopherbot closed 9 years ago
Please, be more specific. Provide a small program for us to demonstrate your problem. For example, I have tried this: package main import ( "fmt" "time" ) func main() { t := time.Now() t1 := t.Hour() //will return GMT time t2 := t.Hour() //will return local time fmt.Printf("t1=%v\n", t1) fmt.Printf("t2=%v\n", t2) } And it prints C:\>go run a.go t1=9 t2=9 which, I suspect, is different from what you see. Please, tell us what your program outputs, and how it is different from what you expect it to do and why. Thank you. Alex
Owner changed to @alexbrainman.
Status changed to WaitingForReply.
souce code: package main import ( "fmt" "time" ) func main() { t := time.Now() fmt.Printf("first call: %v 2nd call: %v \n", t.Hour(),t.Hour()) switch { case t.Hour() < 12: fmt.Println("Good morning!") case t.Hour() < 17: fmt.Println("Good afternoon.") default: fmt.Println("Good evening.") } } run result: D:\myGo>go install timeHour D:\myGo>bin\timehour first call: 2 2nd call: 10 Good morning! D:\myGo>
I think your issue is similar to https://golang.org/issue/3592. It has been fixed some time ago (http://goo.gl/htyjy). Please, try latest Go version. Or at least go1.0.1. Alex
by yangchunxu: