LoadLocation wraps time.LoadLocation which does not perform caching internally and which requires many disk accesses to locate the named zoneinfo file.
(zone string)
| 49 | // caching internally and which requires many disk accesses to |
| 50 | // locate the named zoneinfo file. |
| 51 | func (z *zoneCache) LoadLocation(zone string) (*time.Location, error) { |
| 52 | z.mu.Lock() |
| 53 | entry, ok := z.mu.named[zone] |
| 54 | z.mu.Unlock() |
| 55 | |
| 56 | if !ok { |
| 57 | loc, err := time.LoadLocation(zone) |
| 58 | |
| 59 | entry = &zoneCacheEntry{loc: loc, err: err} |
| 60 | z.mu.Lock() |
| 61 | z.mu.named[zone] = entry |
| 62 | z.mu.Unlock() |
| 63 | } |
| 64 | return entry.loc, entry.err |
| 65 | } |
| 66 | |
| 67 | // FixedZone wraps time.FixedZone. |
| 68 | func (z *zoneCache) FixedZone(hours, minutes, seconds int) *time.Location { |
no test coverage detected