// Load and also updates map if name is not found (to speed up next lookup)
191074
func (runtimeLoader *templateRuntime) templateLoad(name, lang string) (tmpl Template) {
	langName := name
	found := false
	if lang != "" {
		// Look up and return the template.
		langName = name + "." + lang
		tmpl, found = runtimeLoader.templateMap[langName]
		if found {
			return
		}
		tmpl, found = runtimeLoader.templateMap[name]
	} else {
		tmpl, found = runtimeLoader.templateMap[name]
		if found {
			return
		}
	}

	if !found {
		// Neither name is found
		// Look up and return the template.
		for _, engine := range runtimeLoader.templatesAndEngineList {
			if tmpl = engine.Lookup(langName); tmpl != nil {
				found = true
				break
			}
			if tmpl = engine.Lookup(name); tmpl != nil {
				found = true
				break
			}
		}
		if !found {
			return
		}
	}

	// If we found anything store it in the map, we need to copy so we do not
	// run into concurrency issues
	runtimeLoader.loader.templateMutex.Lock()
	defer runtimeLoader.loader.templateMutex.Unlock()

	// In case another thread has loaded the map, reload the atomic value and check
	newRuntimeLoader := runtimeLoader.loader.runtimeLoader.Load().(*templateRuntime)
	if newRuntimeLoader.version != runtimeLoader.version {
		return
	}

	newTemplateMap := map[string]Template{}
	for k, v := range newRuntimeLoader.templateMap {
		newTemplateMap[k] = v
	}
	newTemplateMap[langName] = tmpl
	if _, found := newTemplateMap[name]; !found {
		newTemplateMap[name] = tmpl
	}
	runtimeCopy := &templateRuntime{}
	*runtimeCopy = *newRuntimeLoader
	runtimeCopy.templateMap = newTemplateMap

	// Set the atomic value
	runtimeLoader.loader.runtimeLoader.Store(runtimeCopy)
	return
}
154414
func (s *Settings) Load(props datastore.PropertyMap) error {
	if pdata, ok := props["Settings"]; ok {
		settings := pdata.Slice()
		if len(settings) != 1 {
			return fmt.Errorf("property `Settings` is a property slice")
		}
		settingsBytes, ok := settings[0].Value().([]byte)
		if !ok {
			return fmt.Errorf("expected byte array for property `Settings`")
		}
		if err := proto.Unmarshal(settingsBytes, &s.Settings); err != nil {
			return err
		}
		delete(props, "Settings")
	}
	return datastore.GetPLS(s).Load(props)
}
379453
func (e *EnvironmentLoader) Load(s interface{}) error {
	strct := structs.New(s)
	strctMap := strct.Map()
	prefix := e.getPrefix(strct)

	for key, val := range strctMap {
		field := strct.Field(key)

		if err := e.processField(prefix, field, key, val); err != nil {
			return err
		}
	}

	return nil
}
722306
func (m *Metadata) load(parsedMap map[string]interface{}) {

	// Pull top level things out
	if title, ok := parsedMap["title"]; ok {
		m.Title, _ = title.(string)
	}
	if template, ok := parsedMap["template"]; ok {
		m.Template, _ = template.(string)
	}
	if date, ok := parsedMap["date"].(string); ok {
		for _, layout := range timeLayout {
			if t, err := time.Parse(layout, date); err == nil {
				m.Date = t
				break
			}
		}
	}

	m.Variables = parsedMap
}
261515
func Load(path string, v interface{}) error {
	lock.Lock()
	defer lock.Unlock()
	f, err := os.Open(path)
	if err != nil {
		return err
	}
	defer f.Close()
	return Unmarshal(f, v)
}
828276
func (t *TOMLLoader) Load(s interface{}) error {
	var r io.Reader

	if t.Reader != nil {
		r = t.Reader
	} else if t.Path != "" {
		file, err := getConfig(t.Path)
		if err != nil {
			return err
		}
		defer file.Close()
		r = file
	} else {
		return ErrSourceNotSet
	}

	if _, err := toml.DecodeReader(r, s); err != nil {
		return err
	}

	return nil
}
183927
func (r *GormQueryRepository) Load(ctx context.Context, ID uuid.UUID, spaceID uuid.UUID) (*Query, error) {
	defer goa.MeasureSince([]string{"goa", "db", "query", "show"}, time.Now())
	q := Query{}
	tx := r.db.Where("id = ? and space_id = ?", ID, spaceID).First(&q)
	if tx.RecordNotFound() {
		log.Error(ctx, map[string]interface{}{
			"query_id": ID.String(),
		}, "record not found")
		return nil, errors.NewNotFoundError("query", ID.String())
	}
	if tx.Error != nil {
		log.Error(ctx, map[string]interface{}{
			"err":      tx.Error,
			"query_id": ID.String(),
		}, "unable to load the query by ID")
		return nil, errors.NewInternalError(ctx, tx.Error)
	}
	return &q, nil
}
66784
func Load(ctx context.Context, g *libkb.GlobalContext, lArg keybase1.LoadTeamArg) (*Team, error) {
	teamData, err := g.GetTeamLoader().Load(ctx, lArg)
	if err != nil {
		return nil, err
	}
	ret := NewTeam(ctx, g, teamData)

	if lArg.RefreshUIDMapper {
		// If we just loaded the group, then inform the UIDMapper of any UID->EldestSeqno
		// mappings, so that we're guaranteed they aren't stale.
		ret.refreshUIDMapper(ctx, g)
	}

	return ret, nil
}
581531
func Load(v interface{}, s ...Source) error {
	if reflect.Indirect(reflect.ValueOf(v)).Kind() != reflect.Struct {
		panic("scan for non-struct type")
	}
	if len(s) == 0 {
		return nil
	}
	scn := &scanner{s}
	return scn.scan(v)
}
1109242
func Load(path string, data interface{}) error {
	file, err := os.Open(path)
	if err != nil {
		return err
	}
	defer file.Close()
	decoder := json.NewDecoder(file)
	return decoder.Decode(data)
}
1052334
func (r *GormWorkItemLinkTypeRepository) Load(ctx context.Context, ID uuid.UUID) (*WorkItemLinkType, error) {
	defer goa.MeasureSince([]string{"goa", "db", "workitemlinktype", "load"}, time.Now())
	log.Info(ctx, map[string]interface{}{
		"wilt_id": ID,
	}, "loading work item link type")
	modelLinkType := WorkItemLinkType{}
	db := r.db.Model(&modelLinkType).Where("id=?", ID).First(&modelLinkType)
	if db.RecordNotFound() {
		log.Error(ctx, map[string]interface{}{
			"wilt_id": ID,
		}, "work item link type not found")
		return nil, errors.NewNotFoundError("work item link type", ID.String())
	}
	if db.Error != nil {
		log.Error(ctx, map[string]interface{}{
			"wilt_id": ID,
			"err":     db.Error,
		}, "failed to create work item link type")
		return nil, errors.NewInternalError(ctx, db.Error)
	}
	return &modelLinkType, nil
}
244047
func (a Aggregations) load(i map[string]interface{}) error {
	for k, value := range i {
		valueMap, ok := value.(map[string]interface{})
		if ok {
			agg := &Aggregate{Name: k}
			e := agg.Load(valueMap)
			if e != nil {
				return e
			}
			a[k] = agg
		}
	}
	return nil
}
274302
func (m multiLoader) Load(s interface{}) error {
	for _, loader := range m {
		if err := loader.Load(s); err != nil {
			return err
		}
	}

	return nil
}
510506
func (f *FastTeamChainLoader) load(m libkb.MetaContext, arg fastLoadArg) (res *fastLoadRes, err error) {

	defer m.Trace(fmt.Sprintf("FastTeamChainLoader#load(%+v)", arg), func() error { return err })()

	// Single-flight lock by team ID.
	lock := f.locktab.AcquireOnName(m.Ctx(), m.G(), arg.ID.String())
	defer lock.Release(m.Ctx())

	return f.loadLockedWithRetries(m, arg)
}
455768
func (r *GormTrackerQueryRepository) Load(ctx context.Context, ID uuid.UUID) (*TrackerQuery, error) {
	defer goa.MeasureSince([]string{"goa", "db", "trackerquery", "load"}, time.Now())
	res := TrackerQuery{}
	tx := r.db.Where("id = ?", ID).Find(&res)
	if tx.RecordNotFound() {
		log.Error(ctx, map[string]interface{}{
			"tracker_id": ID.String(),
		}, "tracker resource not found")
		return nil, errors.NewNotFoundError("tracker query", ID.String())
	}
	if tx.Error != nil {
		log.Error(ctx, map[string]interface{}{
			"err":             tx.Error,
			"trackerquery_id": ID,
		}, "unable to load the trackerquery by ID")
		return nil, errors.NewInternalError(ctx, errs.Wrapf(tx.Error, "failed to load the trackerquery by ID: %s", ID))
	}
	return &res, nil
}
125022
func (p *LogPrefix) Load(pmap ds.PropertyMap) error {
	if err := ds.GetPLS(p).Load(pmap); err != nil {
		return err
	}

	// Validate the log prefix. Don't enforce HashID correctness, since datastore
	// hasn't populated that field yet.
	return p.validateImpl(false)
}
1127340
func (y *YAMLLoader) Load(s interface{}) error {
	var r io.Reader

	if y.Reader != nil {
		r = y.Reader
	} else if y.Path != "" {
		file, err := getConfig(y.Path)
		if err != nil {
			return err
		}
		defer file.Close()
		r = file
	} else {
		return ErrSourceNotSet
	}

	data, err := ioutil.ReadAll(r)
	if err != nil {
		return err
	}

	return yaml.Unmarshal(data, s)
}