// FetchVal fetches the specified slash-separated tag and returns the
// value as an interface. It returns nil on error, or if not found.
187041
func FetchVal(vars map[string]interface{}, tags string) interface{} {
	splitTags := strings.Split(tags, "/")
	if len(tags) == 0 {
		return nil
	}
	current := vars
	for _, tag := range splitTags[:len(splitTags)-1] {
		icur, ok := current[tag]
		if !ok {
			return nil
		}
		current, ok = icur.(map[string]interface{})
		if !ok {
			return nil
		}
	}
	return current[splitTags[len(splitTags)-1]]
}
501158
func (mtt *mttNode) fetch(ns []string) []*mttNode {
	node, err := mtt.find(ns)
	if err != nil {
		return nil
	}

	var children []*mttNode

	if node.mts != nil {
		children = append(children, node)
	}
	if node.children != nil {
		children = gatherDescendants(children, node)
	}
	return children
}
483432
func (h *urlDataSource) Fetch(path string) (io.ReadCloser, string, error) {
	dataURL := urlJoin(h.baseURL, path)
	client := utils.GetHTTPClient(h.hostnameVerification)
	// dataURL can be http:// or file://
	// MakeFileURL will only modify the URL if it's a file URL
	dataURL = utils.MakeFileURL(dataURL)
	resp, err := client.Get(dataURL)
	if err != nil {
		logger.Tracef("Got error requesting %q: %v", dataURL, err)
		return nil, dataURL, errors.NotFoundf("invalid URL %q", dataURL)
	}
	if resp.StatusCode != http.StatusOK {
		resp.Body.Close()
		switch resp.StatusCode {
		case http.StatusNotFound:
			return nil, dataURL, errors.NotFoundf("cannot find URL %q", dataURL)
		case http.StatusUnauthorized:
			return nil, dataURL, errors.Unauthorizedf("unauthorised access to URL %q", dataURL)
		}
		return nil, dataURL, fmt.Errorf("cannot access URL %q, %q", dataURL, resp.Status)
	}
	return resp.Body, dataURL, nil
}
1064199
func (sv *SyncVal) Get() interface{} {
	sv.lock.RLock()
	val := sv.val
	sv.lock.RUnlock()
	return val
}
558926
func (v *Object) GetValue(keys ...string) (*Value, error) {
	return v.getPath(keys)
}
739091
func (f *fetcher) Fetch() error {
	resp, err := f.client.Do(f.req)
	if err != nil {
		return errors.Trace(err)
	}

	defer func() {
		err = resp.Body.Close()
		if err != nil {
			logger.Debugf("failed defer %q", errors.Trace(err))
		}
	}()

	if resp.StatusCode != 200 {
		f.image.cleanup()
		return errors.NotFoundf(
			"got %d fetching image %q", resp.StatusCode, path.Base(
				f.req.URL.String()))
	}
	err = f.image.write(resp.Body, f.metadata)
	if err != nil {
		return errors.Trace(err)
	}
	return nil
}
206490
func (wxa *MiniProgram) fetchData(urlStr string, body interface{}) (response []byte, err error) {
	var accessToken string
	accessToken, err = wxa.GetAccessToken()
	if err != nil {
		return
	}
	urlStr = fmt.Sprintf(urlStr, accessToken)
	response, err = util.PostJSON(urlStr, body)
	return
}
82929
func (r *report) fetch(force bool, secs time.Duration) error {
	r.mu.Lock()
	defer r.mu.Unlock()
	if r.p != nil && !force {
		return nil
	}
	if secs == 0 {
		secs = 60 * time.Second
	}
	url := fmt.Sprintf("%s/debug/_gom?view=profile&name=%s", *target, r.name)
	p, err := fetch.FetchProfile(url, secs)
	if err != nil {
		return err
	}
	if err := symbolz.Symbolize(fmt.Sprintf("%s/debug/_gom?view=symbol", *target), fetch.PostURL, p); err != nil {
		return err
	}
	r.p = p
	return nil
}
309496
func (meta Metadata) TryGetValue(key string) ([]byte, bool) {
	if value, isSet := meta[key]; isSet {
		return value, true
	}
	return []byte{}, false
}
54444
func Fetch(baseURL string, resourceType string, id string) (*jsh.Document, *http.Response, error) {
	request, err := FetchRequest(baseURL, resourceType, id)
	if err != nil {
		return nil, nil, err
	}

	return Do(request, jsh.ObjectMode)
}
602978
func (p *parser) getValue(node *html.Node) string {
	var propValue string

	switch node.DataAtom {
	case atom.Meta:
		if value, ok := getAttr("content", node); ok {
			propValue = value
		}
	case atom.Audio, atom.Embed, atom.Iframe, atom.Img, atom.Source, atom.Track, atom.Video:
		if value, ok := getAttr("src", node); ok {
			if u, err := p.baseURL.Parse(value); err == nil {
				propValue = u.String()
			}
		}
	case atom.A, atom.Area, atom.Link:
		if value, ok := getAttr("href", node); ok {
			if u, err := p.baseURL.Parse(value); err == nil {
				propValue = u.String()
			}
		}
	case atom.Data, atom.Meter:
		if value, ok := getAttr("value", node); ok {
			propValue = value
		}
	case atom.Time:
		if value, ok := getAttr("datetime", node); ok {
			propValue = value
		}
	default:
		// The "content" attribute can be found on other tags besides the meta tag.
		if value, ok := getAttr("content", node); ok {
			propValue = value
			break
		}

		var buf bytes.Buffer
		walkNodes(node, func(n *html.Node) {
			if n.Type == html.TextNode {
				buf.WriteString(n.Data)
			}
		})
		propValue = buf.String()
	}

	return propValue
}
1148034
func Fetch(
	src []simplestreams.DataSource,
	cons *imagemetadata.ImageConstraint,
	ff simplestreams.AppendMatchingFunc) ([]*Metadata, *simplestreams.ResolveInfo, error) {
	if ff == nil {
		ff = Filter("")
	}
	params := simplestreams.GetMetadataParams{
		StreamsVersion:   imagemetadata.StreamsVersionV1,
		LookupConstraint: cons,
		ValueParams: simplestreams.ValueParams{
			DataType:      DataType,
			FilterFunc:    ff,
			ValueTemplate: Metadata{},
		},
	}
	items, resolveInfo, err := simplestreams.GetMetadata(src, params)
	if err != nil {
		return nil, resolveInfo, err
	}
	md := make([]*Metadata, len(items))
	for i, im := range items {
		md[i] = im.(*Metadata)
	}

	Sort(md)

	return md, resolveInfo, nil
}
1038445
func (this *Future) loadVal() *futureVal {
	r := atomic.LoadPointer(&this.val)
	return (*futureVal)(r)
}
213584
func (xc *CommonExchange) fetch(request *http.Request, response interface{}) (err error) {
	resp, err := xc.client.Do(request)
	if err != nil {
		return fmt.Errorf(fmt.Sprintf("Request failed: %v", err))
	}
	defer resp.Body.Close()
	err = json.NewDecoder(resp.Body).Decode(response)
	if err != nil {
		return fmt.Errorf(fmt.Sprintf("Failed to decode json from %s: %v", request.URL.String(), err))
	}
	return
}
1358068
func (u Uint) Get() (uint, error) {
	if !u.Present() {
		var zero uint
		return zero, errors.New("value not present")
	}
	return *u.value, nil
}
351469
func fetchJSON(c context.Context, client *http.Client, val interface{}, f func() (*http.Request, error)) error {
	r, err := f()
	if err != nil {
		logging.Errorf(c, "auth: URL fetch failed - %s", err)
		return err
	}
	logging.Infof(c, "auth: %s %s", r.Method, r.URL)
	resp, err := ctxhttp.Do(c, client, r)
	if err != nil {
		logging.Errorf(c, "auth: URL fetch failed, can't connect - %s", err)
		return transient.Tag.Apply(err)
	}
	defer func() {
		ioutil.ReadAll(resp.Body)
		resp.Body.Close()
	}()
	if resp.StatusCode >= 300 {
		body, _ := ioutil.ReadAll(resp.Body)
		// Opportunistically try to unmarshal the response. Works with JSON APIs.
		if val != nil {
			json.Unmarshal(body, val)
		}
		logging.Errorf(c, "auth: URL fetch failed - HTTP %d - %s", resp.StatusCode, string(body))
		err := fmt.Errorf("auth: HTTP code (%d) when fetching %s", resp.StatusCode, r.URL)
		if resp.StatusCode >= 500 {
			return transient.Tag.Apply(err)
		}
		return err
	}
	if val != nil {
		if err = json.NewDecoder(resp.Body).Decode(val); err != nil {
			logging.Errorf(c, "auth: URL fetch failed, bad JSON - %s", err)
			return fmt.Errorf("auth: can't deserialize JSON at %q - %s", r.URL, err)
		}
	}
	return nil
}
1238764
func (kv *KeyValBytes) GetValue(message proto.Message) error {
	return json.Unmarshal(kv.value, message)
}