// Query Functions
// Lookup looks up the ResourceType record with the specified name.  If there is no such record, then
// a gorm.ErrRecordNotFound error will be returned.
425510
func (m *GormResourceTypeRepository) Lookup(ctx context.Context, name string) (*ResourceType, error) {
	defer goa.MeasureSince([]string{"goa", "db", "resource_type", "lookupOrCreate"}, time.Now())

	var native ResourceType
	err := m.db.Table(m.TableName()).Where("name = ?", name).First(&native).Error
	if err == gorm.ErrRecordNotFound {
		return nil, errors.NewNotFoundErrorWithKey("resource_type", "name", name)
	}
	return &native, err
}
56849
func Lookup(service string, entries chan<- *ServiceEntry) error {
	params := DefaultParams(service)
	params.Entries = entries
	return Query(params)
}
585995
func (lkp *lookupInternal) Lookup(vcursor VCursor, ids []sqltypes.Value) ([]*sqltypes.Result, error) {
	results := make([]*sqltypes.Result, 0, len(ids))
	for _, id := range ids {
		bindVars := map[string]*querypb.BindVariable{
			lkp.FromColumns[0]: sqltypes.ValueBindVariable(id),
		}
		var err error
		var result *sqltypes.Result
		if lkp.Autocommit {
			result, err = vcursor.ExecuteAutocommit("VindexLookup", lkp.sel, bindVars, false /* isDML */)
		} else {
			result, err = vcursor.Execute("VindexLookup", lkp.sel, bindVars, false /* isDML */)
		}
		if err != nil {
			return nil, fmt.Errorf("lookup.Map: %v", err)
		}
		results = append(results, result)
	}
	return results, nil
}
1068104
func Lookup(dir string) (Info, error) {
	return Info{}, fmt.Errorf("mount.Lookup is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
}
362126
func (s *Set) Lookup(name interface{}) Option {
	switch v := name.(type) {
	case rune:
		return s.shortOptions[v]
	case int:
		return s.shortOptions[rune(v)]
	case string:
		return s.longOptions[v]
	}
	return nil
}
568802
func Lookup(providerType string) ProviderCreator {
	providersMu.Lock()
	defer providersMu.Unlock()
	return providers[providerType]
}
15448
func (b *BucketLookup) Lookup(ctx context.Context, orgID platform.ID, name string) (platform.ID, bool) {
	oid := platform.ID(orgID)
	filter := platform.BucketFilter{
		OrganizationID: &oid,
		Name:           &name,
	}
	bucket, err := b.BucketService.FindBucket(ctx, filter)
	if err != nil {
		return platform.InvalidID(), false
	}
	return bucket.ID, true
}
359295
func (ms *SQLMsgStore) Lookup(seq uint64) (*pb.MsgProto, error) {
	ms.Lock()
	msg, err := ms.lookup(seq)
	ms.Unlock()
	return msg, err
}
424173
func (t *Trash) Lookup(ctx context.Context,
	req *fuse.LookupRequest, resp *fuse.LookupResponse) (fs.Node, error) {
	if req.Name == strconv.Itoa(os.Getuid()) {
		return &Alias{
			realPath: fmt.Sprintf("../private/%s/.trash", t.kbusername),
		}, nil
	}
	return nil, fuse.ENOENT
}
378457
func (r *Router) Lookup(method string, path string) (httprouter.Handle, httprouter.Params, bool) {
	return r.Router.Lookup(method, path)
}
17255
func (h *Handler) lookup(req *cacheRequest) (*Resource, error) {
	res, err := h.cache.Retrieve(req.Key.String())

	// HEAD requests can possibly be served from GET
	if err == ErrNotFoundInCache && req.Method == "HEAD" {
		res, err = h.cache.Retrieve(req.Key.ForMethod("GET").String())
		if err != nil {
			return nil, err
		}

		if res.HasExplicitExpiration() && req.isCacheable() {
			debugf("using cached GET request for serving HEAD")
			return res, nil
		} else {
			return nil, ErrNotFoundInCache
		}
	} else if err != nil {
		return res, err
	}

	// Secondary lookup for Vary
	if vary := res.Header().Get("Vary"); vary != "" {
		res, err = h.cache.Retrieve(req.Key.Vary(vary, req.Request).String())
		if err != nil {
			return res, err
		}
	}

	return res, nil
}
1021456
func lookupHost(hostname string) (string, error) {
	addrs, err := net.LookupHost(hostname)

	if err != nil {
		return "", err
	}
	return addrs[0], nil
}
1262881
func (ctx *Context) Query(name string) string {
	if ctx.query == nil {
		ctx.query = ctx.Req.URL.Query()
	}
	return ctx.query.Get(name)
}
482721
func (r *Resolver) Lookup(instance, service, domain string, entries chan<- *ServiceEntry) error {
	params := defaultParams(service)
	params.Instance = instance
	if domain != "" {
		params.Domain = domain
	}
	params.Entries = entries

	go r.c.mainloop(params)

	err := r.c.query(params)
	if err != nil {
		r.Exit <- true
		return err
	}

	return nil
}
1140168
func (t *templateHandler) Lookup(name string) (tpl.Template, bool) {

	if strings.HasPrefix(name, textTmplNamePrefix) {
		// The caller has explicitly asked for a text template, so only look
		// in the text template collection.
		// The templates are stored without the prefix identificator.
		name = strings.TrimPrefix(name, textTmplNamePrefix)

		return t.applyTemplateInfo(t.text.Lookup(name))
	}

	// Look in both
	if te, found := t.html.Lookup(name); found {
		return t.applyTemplateInfo(te, true)
	}

	return t.applyTemplateInfo(t.text.Lookup(name))

}
1230776
func (s *Directory) Lookup(ctx context.Context, name string) (fs.Node, error) {
	child, err := s.dir.Child(name)
	if err != nil {
		// todo: make this error more versatile.
		return nil, fuse.ENOENT
	}

	switch child := child.(type) {
	case *mfs.Directory:
		return &Directory{dir: child}, nil
	case *mfs.File:
		return &FileNode{fi: child}, nil
	default:
		// NB: if this happens, we do not want to continue, unpredictable behaviour
		// may occur.
		panic("invalid type found under directory. programmer error.")
	}
}
207761
func (r Routefinder) Lookup(path string) (string, map[string]string) {
	// Dump any query string
	normalizedPath := strings.SplitN(path, "?", 2)[0]

	// Check key against regex'es
	for _, template := range r {
		// Get the prefix of the regex and test it
		if !strings.HasPrefix(normalizedPath, template.prefix) {
			continue
		}

		// Is the prefix == the whole thing? Then a match == win
		if !template.hasVars && normalizedPath == template.name {
			return template.name, map[string]string{}
		}

		// Check key against regexes
		if !template.re.MatchString(normalizedPath) {
			continue
		}

		subMatchNames := template.re.SubexpNames()
		subMatchValues := template.re.FindStringSubmatch(normalizedPath)

		meta := make(map[string]string, len(subMatchNames))

		for j := 1; j < len(subMatchNames); j++ {
			meta[subMatchNames[j]] = subMatchValues[j]
		}

		templateName := template.name

		// If the template ends with /... and we extracted __TRAILING__, transplant it back
		if trailing, ok := meta["__TRAILING__"]; ok && strings.HasSuffix(template.name, "/...") {
			templateName = templateName[:len(templateName)-3] + trailing
			delete(meta, "__TRAILING__")
		}

		if _, ok := meta["__DISCARD__"]; ok && strings.HasSuffix(template.name, "/???") {
			delete(meta, "__DISCARD__")
		}

		return templateName, meta
	}

	return "", map[string]string{}
}