Example #1
0
func (c *Command) fetch(query string) (string, error) {
	var t message
	url := utils.EncodeURL(apiURL, query)
	if err := utils.FetchURL(url, &t); err != nil {
		return "", err
	}
	return t.Abstract, nil
}
Example #2
0
// fetch queries the apiURL with the given query and populates the p Command.
func (c *Command) fetch(query string) error {
	var t message
	url := utils.EncodeURL(apiURL, query)
	err := utils.FetchURL(url, &t)
	if err != nil {
		return err
	}
	if len(t.List) == 0 {
		return errors.New("No result")
	}
	c.Last = t
	c.Current = 0
	c.CurrentResult = t.List[c.Current]
	c.sanitize()
	return nil
}