search

package
v1.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2016 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package search provides search interface and functionality

Index

Constants

This section is empty.

Variables

View Source
var (
	// Logger is the logger
	Logger *log.Logger
)

Functions

func DoRequest added in v1.4.0

func DoRequest(ctx context.Context, req *http.Request, f func(*http.Response, error) error) error

DoRequest makes a HTTP request with context

func ParseGoto added in v1.5.1

func ParseGoto(g string) int

ParseGoto parses goto from a given string

func ParsePage added in v1.5.1

func ParsePage(p string) int

ParsePage parses page from a given string

func ParseTimeout added in v1.5.1

func ParseTimeout(t string) time.Duration

ParseTimeout parses timeout from a given string

func PrintResults added in v1.5.0

func PrintResults(query Query, err error)

PrintResults prints the given search results

func Register

func Register(name string, provider interface{}) error

Register registers a search provider

func Searchers added in v1.5.2

func Searchers() []string

Searchers returns a sorted list of the names of the registered searchers

Types

type Query added in v1.5.0

type Query struct {
	Provider string
	Keyword  string
	Page     int
	Goto     int
	Timeout  time.Duration
	Start    time.Time
	Elapsed  time.Duration
	Results  Results
}

Query represents a search query

func Do added in v1.5.1

func Do(ctx context.Context, query Query) (Query, error)

Do makes a query by the given context and query

type Result added in v1.4.0

type Result struct {
	Description string
	Link        string
}

Result represents a search result

type Results added in v1.4.0

type Results []Result

Results represents a list of search results

func (Results) Len added in v1.4.0

func (r Results) Len() int

Sort implementation

func (Results) Less added in v1.4.0

func (r Results) Less(i, j int) bool

func (Results) Swap added in v1.4.0

func (r Results) Swap(i, j int)

type Searcher

type Searcher interface {
	// Search makes a search
	Search(ctx context.Context, args map[string]interface{}) ([]map[string]interface{}, error)
}

Searcher is the interface that must be implemented by a search provider

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL