From 6b0026ae31720a01f846335d05e42e67e3a2a7cc Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Wed, 29 Sep 2021 02:19:34 +0000 Subject: [PATCH] time: add doc comment about tzdata package Add doc comment about the time/tzdata package to the time.LoadLocation function. The time.LoadLocation function was changed in Go 1.15 to add an extra source that it considers for the time zone database. That location is the time/tzdata package. It is not easy to discover this behavior because the documentation for the time package doesn't mention it in the discussion on the time.LoadLocation function when discussing the different sources. It would be helpful to describe all possible sources that time.LoadLocation considers when loading the time zone database, and so I think it would be worthwhile to mention time/tzdata. Change-Id: I408fbe188bf9d4ba797e59ec17eb677136d6a9c2 GitHub-Last-Rev: 3dac204326960a18c4e44d3ea24fd428e91e9fcb GitHub-Pull-Request: golang/go#48673 Reviewed-on: https://go-review.googlesource.com/c/go/+/352830 Reviewed-by: Ian Lance Taylor Trust: Heschi Kreinick --- src/time/zoneinfo.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/time/zoneinfo.go b/src/time/zoneinfo.go index 57aed03fec..7b39f869e6 100644 --- a/src/time/zoneinfo.go +++ b/src/time/zoneinfo.go @@ -631,12 +631,13 @@ var zoneinfoOnce sync.Once // Otherwise, the name is taken to be a location name corresponding to a file // in the IANA Time Zone database, such as "America/New_York". // -// The time zone database needed by LoadLocation may not be -// present on all systems, especially non-Unix systems. -// LoadLocation looks in the directory or uncompressed zip file -// named by the ZONEINFO environment variable, if any, then looks in -// known installation locations on Unix systems, -// and finally looks in $GOROOT/lib/time/zoneinfo.zip. +// LoadLocation looks for the IANA Time Zone database in the following +// locations in order: +// +// - the directory or uncompressed zip file named by the ZONEINFO environment variable +// - on a Unix system, the system standard installation location +// - $GOROOT/lib/time/zoneinfo.zip +// - the time/tzdata package, if it was imported func LoadLocation(name string) (*Location, error) { if name == "" || name == "UTC" { return UTC, nil -- 2.50.0