time.LoadLocation not working on play.golang.org?

1,344 views
Skip to first unread message

Lobatt

unread,
Feb 26, 2014, 11:03:33 AM2/26/14
to golan...@googlegroups.com
Check this: http://play.golang.org/p/s77bcLYHax

Also pasted below:
package main

import "fmt"
import "time"
func main() {
t := time.Now()
loc, err := time.LoadLocation("America/New_York")
if err != nil {
fmt.Printf("Error: %s\n", err)
}
fmt.Printf("UTC %s, Local time: %s, tz %s\n", t.UTC().Format(time.RFC3339), t.In(loc).Format(time.RFC3339), loc.String())
}

output:
Error: unknown time zone America/New_York
panic: time: missing Location in call to Time.In

And on my mac this program worked fine,
output:
UTC 2014-02-26T15:56:58Z, Local time: 2014-02-26T10:56:58-05:00, tz America/New_York

Just want to make sure that I didn't created a bug in my code that could be triggered on other platforms.

Matthew Zimmerman

unread,
Feb 26, 2014, 11:34:39 AM2/26/14
to Lobatt, golang-nuts

The location information is pulled from the local filesystem.  Most systems will support it but it does depend what is loaded on the particular system.  As always, catch and handle your errors ☺

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Lobatt

unread,
Feb 26, 2014, 11:45:31 AM2/26/14
to golan...@googlegroups.com
Thanks for replying and for the advice, Matthew!

Also I checked the doc, I thought for any go installation, there will always be a $GOROOT/lib/time/zoneinfo.zip presented in the filesystem, maybe play.golang.org need some configuration tweaks?

Matthew Zimmerman

unread,
Feb 26, 2014, 1:41:36 PM2/26/14
to Lobatt, golang-nuts
I've experienced issues with LoadLocation on the Go Playground and
also on AppEngine so that's why I say it varies. AppEngine is
supposed to be fixed with the next deployment.
https://groups.google.com/forum/#!msg/google-appengine-go/0z015BKW_-Q/Ru16-C71POYJ

Ian Lance Taylor

unread,
Feb 26, 2014, 1:42:43 PM2/26/14
to Lobatt, golang-nuts
On Wed, Feb 26, 2014 at 8:45 AM, Lobatt <lob...@gmail.com> wrote:
>
> Also I checked the doc, I thought for any go installation, there will always
> be a $GOROOT/lib/time/zoneinfo.zip presented in the filesystem, maybe
> play.golang.org need some configuration tweaks?

This is http://golang.org/issue/4755 .

Ian
Reply all
Reply to author
Forward
0 new messages