2021-01-15 21:29:14 +00:00
|
|
|
From f3d446b60a082308ec5aaa2fdc36e31f566081bb Mon Sep 17 00:00:00 2001
|
2018-05-03 09:11:48 +00:00
|
|
|
From: =?UTF-8?q?Jakub=20=C4=8Cajka?= <jcajka@redhat.com>
|
2021-01-15 21:29:14 +00:00
|
|
|
Date: Thu, 22 Mar 2018 11:49:09 +0100
|
2018-05-03 09:11:48 +00:00
|
|
|
Subject: [PATCH 1/3] Don't use the bundled tzdata at runtime, except for the
|
|
|
|
internal test suite
|
|
|
|
|
|
|
|
---
|
|
|
|
src/time/internal_test.go | 7 +++++--
|
|
|
|
src/time/zoneinfo_test.go | 3 ++-
|
|
|
|
src/time/zoneinfo_unix.go | 2 --
|
|
|
|
3 files changed, 7 insertions(+), 5 deletions(-)
|
|
|
|
|
|
|
|
diff --git a/src/time/internal_test.go b/src/time/internal_test.go
|
2021-01-15 21:29:14 +00:00
|
|
|
index 35ce69b228..1cea04ed7e 100644
|
2018-05-03 09:11:48 +00:00
|
|
|
--- a/src/time/internal_test.go
|
|
|
|
+++ b/src/time/internal_test.go
|
2018-01-03 12:22:17 +00:00
|
|
|
@@ -4,13 +4,15 @@
|
|
|
|
|
|
|
|
package time
|
|
|
|
|
|
|
|
+import "runtime"
|
|
|
|
+
|
|
|
|
func init() {
|
|
|
|
// force US/Pacific for time zone tests
|
|
|
|
ForceUSPacificForTesting()
|
|
|
|
}
|
|
|
|
|
|
|
|
func initTestingZone() {
|
|
|
|
- z, err := loadLocation("America/Los_Angeles", zoneSources[len(zoneSources)-1:])
|
|
|
|
+ z, err := loadLocation("America/Los_Angeles", zoneSources)
|
|
|
|
if err != nil {
|
|
|
|
panic("cannot load America/Los_Angeles for testing: " + err.Error())
|
|
|
|
}
|
|
|
|
@@ -21,8 +23,9 @@ func initTestingZone() {
|
|
|
|
var OrigZoneSources = zoneSources
|
|
|
|
|
|
|
|
func forceZipFileForTesting(zipOnly bool) {
|
|
|
|
- zoneSources = make([]string, len(OrigZoneSources))
|
|
|
|
+ zoneSources = make([]string, len(OrigZoneSources)+1)
|
|
|
|
copy(zoneSources, OrigZoneSources)
|
|
|
|
+ zoneSources = append(zoneSources, runtime.GOROOT()+"/lib/time/zoneinfo.zip")
|
|
|
|
if zipOnly {
|
|
|
|
zoneSources = zoneSources[len(zoneSources)-1:]
|
|
|
|
}
|
2018-05-03 09:11:48 +00:00
|
|
|
diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go
|
2021-01-15 21:29:14 +00:00
|
|
|
index 277b68f798..be2aa6c687 100644
|
2018-05-03 09:11:48 +00:00
|
|
|
--- a/src/time/zoneinfo_test.go
|
|
|
|
+++ b/src/time/zoneinfo_test.go
|
2021-01-15 21:29:14 +00:00
|
|
|
@@ -9,6 +9,7 @@ import (
|
2018-01-03 12:22:17 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"reflect"
|
|
|
|
+ "runtime"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
2021-01-15 21:29:14 +00:00
|
|
|
@@ -139,7 +140,7 @@ func TestLoadLocationFromTZData(t *testing.T) {
|
2018-01-03 12:22:17 +00:00
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
- tzinfo, err := time.LoadTzinfo(locationName, time.OrigZoneSources[len(time.OrigZoneSources)-1])
|
|
|
|
+ tzinfo, err := time.LoadTzinfo(locationName, runtime.GOROOT()+"/lib/time/zoneinfo.zip")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
2018-05-03 09:11:48 +00:00
|
|
|
diff --git a/src/time/zoneinfo_unix.go b/src/time/zoneinfo_unix.go
|
2021-01-15 21:29:14 +00:00
|
|
|
index d2465eef65..b8c934c9a9 100644
|
2018-05-03 09:11:48 +00:00
|
|
|
--- a/src/time/zoneinfo_unix.go
|
|
|
|
+++ b/src/time/zoneinfo_unix.go
|
2018-01-03 12:22:17 +00:00
|
|
|
@@ -12,7 +12,6 @@
|
|
|
|
package time
|
|
|
|
|
|
|
|
import (
|
|
|
|
- "runtime"
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
@@ -22,7 +21,6 @@ var zoneSources = []string{
|
2015-08-25 18:10:59 +00:00
|
|
|
"/usr/share/zoneinfo/",
|
|
|
|
"/usr/share/lib/zoneinfo/",
|
|
|
|
"/usr/lib/locale/TZ/",
|
|
|
|
- runtime.GOROOT() + "/lib/time/zoneinfo.zip",
|
|
|
|
}
|
|
|
|
|
2018-01-03 12:22:17 +00:00
|
|
|
func initLocal() {
|
2018-05-03 09:11:48 +00:00
|
|
|
--
|
2021-01-15 21:29:14 +00:00
|
|
|
2.26.2
|
2018-05-03 09:11:48 +00:00
|
|
|
|