// getLoc first trying to load location from a cache map. If nothing found in such map, then call
// `time.LoadLocation` to get a timezone location. After trying both way, an error will be returned
//  if valid Location is not found.
170946
func (lm *locCache) getLoc(name string) (*time.Location, error) {
	if name == "System" {
		return time.Local, nil
	}
	lm.RLock()
	v, ok := lm.locMap[name]
	lm.RUnlock()
	if ok {
		return v, nil
	}

	if loc, err := time.LoadLocation(name); err == nil {
		// assign value back to map
		lm.Lock()
		lm.locMap[name] = loc
		lm.Unlock()
		return loc, nil
	}

	return nil, fmt.Errorf("invalid name for timezone %s", name)
}
1186638
func (p *V2) GetLocations() ([]common.Location, error) {
	p.RLock()
	defer p.RUnlock()
	if len(p.locations) == 0 {
		return nil, common.ErrNotFound
	}
	locations := make([]common.Location, len(p.locations))
	i := 0
	for _, location := range p.locations {
		locations[i] = location
		i++
	}

	return locations, nil
}
579446
func (lic *LocalImageCache) GetCache(imgID string, config *containertypes.Config) (string, error) {
	return getImageIDAndError(getLocalCachedImage(lic.store, image.ID(imgID), config))
}
1372492
func (a *asc) Get() (readSeekCloser, error) {
	if a.Fetcher != nil {
		return a.Fetcher.Get(a.Location)
	}
	return NopReadSeekCloser(nil), nil
}
808577
func (l *Locale) GetC(str, ctx string, vars ...interface{}) string {
	return l.GetDC(l.GetDomain(), str, ctx, vars...)
}
609327
func (c cachedGeocoder) Geocode(address string) (*geo.Location, error) {
	// Check if we've cached this response
	if cachedLoc, found := c.Cache.Get(address); found {
		return cachedLoc.(*geo.Location), nil
	}

	if loc, err := c.Geocoder.Geocode(address); err != nil {
		return loc, err
	} else {
		c.Cache.Set(address, loc, 0)
		return loc, nil
	}
}
679565
func GetTimeStringWithZone(t time.Time, location string) string {
	loc, _ := time.LoadLocation(location)

	localTime := t.In(loc)

	year, month, day := localTime.Date()

	return fmt.Sprintf("%d/%d/%d %d:%d:%d",
		month, day, year, localTime.Hour(), localTime.Minute(), localTime.Second())
}
404584
func (c *Context) GetUniformLocation(program *js.Object, name string) *js.Object {
	return c.Call("getUniformLocation", program, name)
}
80951
func (c Cache) Get(k interface{}) (interface{}, bool) {
	v, ok := c[k]
	return v, ok
}
1319894
func (r Location_Reservation) GetLocationReservationRack() (resp datatypes.Location_Reservation_Rack, err error) {
	err = r.Session.DoRequest("SoftLayer_Location_Reservation", "getLocationReservationRack", nil, &r.Options, &resp)
	return
}
135462
func constructTimeZone(name string, offset int) (*time.Location, error) {
	if name != "" {
		return timeutil.LoadLocation(name)
	}

	return time.FixedZone("", offset), nil
}
1328420
func WithLocation(loc *time.Location) Option {
	return option.New(optkeyClock, clockFn(func() time.Time {
		return time.Now().In(loc)
	}))
}
314410
func (c *Cache) Get(u interface{}) (i interface{}, err error) {

	c.Lock()
	defer c.Unlock()

	if _, ok := c.data[u]; !ok {
		return nil, errors.New("not found")
	}

	return c.data[u].value, nil
}
39320
func (charts *ChartData) getCache(chartID string, zoom ZoomLevel) (data *cachedChart, found bool, cacheID uint64) {
	// Ignore zero length since bestHeight would just be set to zero anyway.
	ck := cacheKey(chartID, zoom)
	charts.cacheMtx.RLock()
	defer charts.cacheMtx.RUnlock()
	cacheID = charts.cacheID(zoom)
	data, found = charts.cache[ck]
	return
}
1058171
func (gi *GeoIP) GetLocationByIPNum(ipNum uint32) *Location {
	// Perform the lookup on the database to see if the record is found
	offset := gi.lookupByIPNum(ipNum)

	// Check if the country was found
	if gi.dbType == dbCountryEdition && offset-countryBegin == 0 ||
		gi.dbType != dbCountryEdition && gi.databaseSegment == offset {
		return nil
	}

	// Create a generic location structure
	location := new(Location)

	// If the database is country
	if gi.dbType == dbCountryEdition {
		location.CountryCode = countryCode[offset-countryBegin]
		location.CountryName = countryName[offset-countryBegin]

		return location
	}

	// Find the max record length
	recPointer := offset + (2*gi.recordLength-1)*gi.databaseSegment
	recordEnd := recPointer + fullRecordLength
	if len(gi.data)-recPointer < fullRecordLength {
		recordEnd = len(gi.data)
	}

	// Read the country code/name first
	location.CountryCode = countryCode[gi.data[recPointer]]
	location.CountryName = countryName[gi.data[recPointer]]
	readLen := 1
	recPointer += 1

	// Get the region
	for readLen = 0; gi.data[recPointer+readLen] != '\000' &&
		recPointer+readLen < recordEnd; readLen++ {
	}
	if readLen != 0 {
		location.Region = string(gi.data[recPointer : recPointer+readLen])
	}
	recPointer += readLen + 1

	// Get the city
	for readLen = 0; gi.data[recPointer+readLen] != '\000' &&
		recPointer+readLen < recordEnd; readLen++ {
	}
	if readLen != 0 {
		location.City = string(gi.data[recPointer : recPointer+readLen])
	}
	recPointer += readLen + 1

	// Get the postal code
	for readLen = 0; gi.data[recPointer+readLen] != '\000' &&
		recPointer+readLen < recordEnd; readLen++ {
	}
	if readLen != 0 {
		location.PostalCode = string(gi.data[recPointer : recPointer+readLen])
	}
	recPointer += readLen + 1

	// Get the latitude
	coordinate := float32(0)
	for j := 0; j < 3; j++ {
		coordinate += float32(int32(gi.data[recPointer+j]) << uint8(j*8))
	}
	location.Latitude = float32(coordinate/10000 - 180)
	recPointer += 3

	// Get the longitude
	coordinate = 0
	for j := 0; j < 3; j++ {
		coordinate += float32(int32(gi.data[recPointer+j]) << uint8(j*8))
	}
	location.Longitude = float32(coordinate/10000 - 180)

	return location
}
923191
func (t *timedCache) Get(key string) (interface{}, error) {
	entry, err := t.getInternal(key)
	if err != nil {
		return nil, err
	}

	// Data is still not cached yet, cache it by getter.
	if entry.data == nil {
		entry.lock.Lock()
		defer entry.lock.Unlock()

		if entry.data == nil {
			data, err := t.getter(key)
			if err != nil {
				return nil, err
			}

			entry.data = data
		}
	}

	return entry.data, nil
}
463678
func getLocation(browser, libpath string, globalInstall bool) (string, error) {
	if globalInstall {
		return getGlobalLocation(browser, libpath)
	}

	pm, found := manifestPath[runtime.GOOS]
	if !found {
		return "", fmt.Errorf("platform %s is currently not supported", runtime.GOOS)
	}
	path, found := pm[browser]
	if !found {
		return "", fmt.Errorf("browser %s on %s is currently not supported", browser, runtime.GOOS)
	}
	return path, nil
}