mirror of
https://github.com/hanzo-ds/go.git
synced 2026-10-30 19:45:01 +00:00
Feature-complete v2.44.0 (lib/churl, lib/col, BFloat16, QBit, scanTypeDuration, Options.Logger *slog.Logger) — fixes the [email protected].0 downgrade RED caught. Package datastore, module github.com/hanzo-ds/go, depends only on hanzo-ds/native. Wire strings preserved VERBATIM (X-ClickHouse-* headers, sql.Register("clickhouse"), clickhouse:// DSN, ClientName="clickhouse-go") — consistent with native.
28 lines
442 B
Go
28 lines
442 B
Go
package timezone
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
var cache = struct {
|
|
mutex sync.Mutex
|
|
items map[string]*time.Location
|
|
}{
|
|
items: make(map[string]*time.Location),
|
|
}
|
|
|
|
func Load(name string) (*time.Location, error) {
|
|
cache.mutex.Lock()
|
|
defer cache.mutex.Unlock()
|
|
if tz, found := cache.items[name]; found {
|
|
return tz, nil
|
|
}
|
|
tz, err := time.LoadLocation(name)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
cache.items[name] = tz
|
|
return tz, nil
|
|
}
|