duden

package module
v0.0.0-...-c27bb6a Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2017 License: MIT Imports: 10 Imported by: 0

README

Build Status GoDoc License

In development

Install

go get github.com/alexdreptu/duden/duden

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoResults returns an error when there are no results for word
	ErrNoResults = func(word string) error {
		return fmt.Errorf("no results for '%s'", word)
	}

	// ErrInvalidResultPos returns an error when result position is invalid
	ErrInvalidResultPos = func(pos int) error {
		return fmt.Errorf("invalid result position '%d'", pos)
	}

	// ErrInvalidWordPos returns an error when word position is invalid
	ErrInvalidWordPos = func(pos int) error {
		return fmt.Errorf("invalid word position '%d'", pos)
	}

	// ErrInvalidDefPos returns an error when definition position is invalid
	ErrInvalidDefPos = func(pos int) error {
		return fmt.Errorf("invalid definition position '%d'", pos)
	}

	// ErrNoResultAtPos returns an error when a result
	// doesn't exist at position pos
	ErrNoResultAtPos = func(pos int) error {
		return fmt.Errorf("no result at position '%d'", pos)
	}

	// ErrNoWordAtPos returns an error when a word
	// doesn't exist in results at position pos
	ErrNoWordAtPos = func(pos int) error {
		return fmt.Errorf("no word at position '%d'", pos)
	}

	// ErrNoDefAtPos returns an error when a definition
	// doesn't exist in results at position pos
	ErrNoDefAtPos = func(pos int) error {
		return fmt.Errorf("no definition at position '%d'", pos)
	}
)

Functions

This section is empty.

Types

type Duden

type Duden struct {
	Results []Result
}

Duden holds the results

func Search(word string, opt Options) (Duden, error)

Search returns a Duden and an error if something goes wrong

func (Duden) GetDefinition

func (d Duden) GetDefinition(pos int) (string, error)

GetDefinition returns a string with the definition at position pos in results otherwise returns an error if something goes wrong

func (Duden) GetLength

func (d Duden) GetLength() int

GetLength returns the total number of results

func (Duden) GetResult

func (d Duden) GetResult(pos int) (Result, error)

GetResult returns a Result containing result at position pos

func (Duden) GetResults

func (d Duden) GetResults() []Result

GetResults returns all the results

func (Duden) GetWord

func (d Duden) GetWord(pos int) (string, error)

GetWord returns a string with the word at position pos in results oterwise returns an error if something goes wrong

type Options

type Options struct {
	Timeout     time.Duration
	FollowPages bool
}

Options holds the options

type Result

type Result struct {
	Word       string
	Definition string
}

Result holds a single result

func (Result) String

func (r Result) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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