dictionaryapi

package
v0.0.0-...-1cbc9ae Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("word not found")

ErrNotFound is returned when word is not found

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements integration with DictionaryAPI docs: https://dictionaryapi.dev/

func NewClient

func NewClient(ctx context.Context) Client

NewClient creates Client with default HTTP client

func (*Client) Get

func (c *Client) Get(word string) (items []WordResponse, err error)

Get returns dictionary item by word

type Definition

type Definition struct {
	Definition string   `json:"definition"`
	Example    string   `json:"example"`
	Synonyms   []string `json:"synonyms"`
	Antonyms   []string `json:"antonyms"`
}

Definition holds information for a definition

type Meaning

type Meaning struct {
	PartOfSpeech string       `json:"partOfSpeech"`
	Definitions  []Definition `json:"definitions"`
}

Meaning holds information for a meaning

type Phonetic

type Phonetic struct {
	Text  string  `json:"text"`
	Audio *string `json:"Audio"`
}

Phonetic holds information for a phonetic pronunciation

type WordResponse

type WordResponse struct {
	Word      string     `json:"word"`
	Phonetic  string     `json:"phonetic"`
	Phonetics []Phonetic `json:"phonetics"`
	Origin    string     `json:"origin"`
	Meanings  []Meaning  `json:"meanings"`
}

WordResponse holds information for an API response

Jump to

Keyboard shortcuts

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