You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.4 KiB
88 lines
2.4 KiB
From edce31a2904846ae74e3c011f2cf5fddc963459e Mon Sep 17 00:00:00 2001 |
|
From: =?UTF-8?q?Jakub=20=C4=8Cajka?= <jcajka@redhat.com> |
|
Date: Thu, 22 Mar 2018 12:07:32 +0100 |
|
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 |
|
index 76d5524124..e81ace5f64 100644 |
|
--- a/src/time/internal_test.go |
|
+++ b/src/time/internal_test.go |
|
@@ -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:] |
|
} |
|
diff --git a/src/time/zoneinfo_test.go b/src/time/zoneinfo_test.go |
|
index 7a55d4f618..6063ca1195 100644 |
|
--- a/src/time/zoneinfo_test.go |
|
+++ b/src/time/zoneinfo_test.go |
|
@@ -8,6 +8,7 @@ import ( |
|
"fmt" |
|
"os" |
|
"reflect" |
|
+ "runtime" |
|
"testing" |
|
"time" |
|
) |
|
@@ -128,7 +129,7 @@ func TestLoadLocationFromTZData(t *testing.T) { |
|
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) |
|
} |
|
diff --git a/src/time/zoneinfo_unix.go b/src/time/zoneinfo_unix.go |
|
index 88313aa0ed..d9596115ef 100644 |
|
--- a/src/time/zoneinfo_unix.go |
|
+++ b/src/time/zoneinfo_unix.go |
|
@@ -12,7 +12,6 @@ |
|
package time |
|
|
|
import ( |
|
- "runtime" |
|
"syscall" |
|
) |
|
|
|
@@ -22,7 +21,6 @@ var zoneSources = []string{ |
|
"/usr/share/zoneinfo/", |
|
"/usr/share/lib/zoneinfo/", |
|
"/usr/lib/locale/TZ/", |
|
- runtime.GOROOT() + "/lib/time/zoneinfo.zip", |
|
} |
|
|
|
func initLocal() { |
|
-- |
|
2.14.3 |
|
|
|
|