goduckgo: github.com/ajanicij/goduckgo/goduckgo Index | Files

package goduckgo

import "github.com/ajanicij/goduckgo/goduckgo"

Package goduckgo provides the functionality for using DuckDuckGo API. For the description of the API, visit http://duckduckgo.com/api.html.


Package Files


func Do Uses

func Do(url string) ([]byte, error)

Do the HTTP requests against API and handle errors

func EncodeUrl Uses

func EncodeUrl(query string) string

EncodeUrl given a text query

type Icon Uses

type Icon struct {
    URL    string
    Height interface{} // can be string or number ("16" or 16)
    Width  interface{} // can be string or number ("16" or 16)

Icon associated with related topics

URL: URL of icon
Height: height of icon (px)
Width: width of icon (px)

func (*Icon) IsEmpty Uses

func (icon *Icon) IsEmpty() bool

IsEmpty if all Icon fields are empty

func (*Icon) Show Uses

func (icon *Icon) Show(prefix string)

Show Show as standard output

type Message Uses

type Message struct {
    Definition       string
    DefinitionSource string
    Heading          string
    AbstractText     string
    Abstract         string
    AbstractSource   string
    Image            string
    Type             string
    AnswerType       string
    Redirect         string
    DefinitionURL    string
    Answer           string
    AbstractURL      string
    Results          Results
    RelatedTopics    RelatedTopics

Message is a structure containing all the information returned by DDG for a query.

Abstract: topic summary (can contain HTML, e.g. italics)
AbstractText: topic summary (with no HTML)
AbstractSource: name of Abstract source
AbstractURL: deep link to expanded topic page in AbstractSource
Image: link to image that goes with Abstract
Heading: name of topic that goes with Abstract
Answer: instant answer
AnswerType: type of Answer, e.g. calc, color, digest, info, ip, iploc, phone, pw, rand, regexp, unicode, upc, or zip (see goodies & tech pages for examples).
Definition: dictionary definition (may differ from Abstract)
DefinitionSource: name of Definition source
DefinitionURL: deep link to expanded definition page in DefinitionSource
RelatedTopics: array of internal links to related topics associated with Abstract
Results: array of external links associated with Abstract
Type: response category, i.e. A (article), D (disambiguation), C (category), N (name), E (exclusive), or nothing.
Redirect: !bang redirect URL

func Query Uses

func Query(query string) (*Message, error)

Query the API given a text query, returns a Message

func (*Message) Decode Uses

func (message *Message) Decode(body []byte) error

Decode a message given a HTTP response body

type RelatedTopic Uses

type RelatedTopic struct {
    Result   string
    Icon     Icon
    FirstURL string
    Text     string

RelatedTopic is a internal link to related topics associated with Abstract

	 Result: HTML link to a related topic
  FirstURL: first URL in Result
  Icon: icon associated with related topic
	 Text: text from first URL

func (*RelatedTopic) Show Uses

func (topic *RelatedTopic) Show(prefix string)

Show RelatedTopic as standard output

type RelatedTopics Uses

type RelatedTopics []RelatedTopic

type Result Uses

type Result RelatedTopic

Result is an external link associated with Abstract

Result: HTML link(s) to external site(s)
FirstURL: first URL in Result
Icon: icon associated with FirstURL
Text: text from FirstURL

func (*Result) Show Uses

func (result *Result) Show(prefix string)

Show Result as standard output

type Results Uses

type Results []Result

Package goduckgo imports 8 packages (graph) and is imported by 9 packages. Updated 2016-07-22. Refresh now. Tools for package owners.