I am converting a function from PHP to Go.
I want to get timezone from country code in Go. It is similar this function in PHP
public static array DateTimeZone::listIdentifiers ([ int $what = DateTimeZone::ALL [, string $country = NULL ]] )
Which function have similar feature in Go?
The Go standard library does not have a function for this. Look for an open-source Go package that does this for you. Or, since this is Go, write a simple Go function yourself. You will have to download the IANA tzdata zone cross-reference file.
For example,
Output:
The timezone is accessible from time.LoadLocation(): example
As seen in golang/go issue 21881, it won't work on Windows because
$GOROOT/lib/time/zoneinfo.zip
is not included by default, hence the need for projects like 4d63.com/tz.