LoadLocation wraps time.LoadLocation which does not perform caching internally and which requires many disk accesses to locate the named zoneinfo file.
(zone string)
| 63 | // caching internally and which requires many disk accesses to |
| 64 | // locate the named zoneinfo file. |
| 65 | func (z *zoneCache) LoadLocation(zone string) (*time.Location, error) { |
| 66 | z.mu.Lock() |
| 67 | entry, ok := z.mu.named[zone] |
| 68 | z.mu.Unlock() |
| 69 | |
| 70 | if !ok { |
| 71 | loc, err := time.LoadLocation(zone) |
| 72 | |
| 73 | entry = &zoneCacheEntry{loc: loc, err: err} |
| 74 | z.mu.Lock() |
| 75 | z.mu.named[zone] = entry |
| 76 | z.mu.Unlock() |
| 77 | } |
| 78 | return entry.loc, entry.err |
| 79 | } |
| 80 | |
| 81 | // FixedZone wraps time.FixedZone. |
| 82 | func (z *zoneCache) FixedZone(hours, minutes, seconds int) *time.Location { |
no test coverage detected