dictionaryapi

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2022 License: MIT Imports: 6 Imported by: 1

README

dictionaryapi

A lightweight go module to access meanings of words using dictionaryapi.dev

Build Release reference Go Report Card codecov Quality Gate Status

Features

  • Get the meaning of a word

Installation

go get github.com/atselvan/dictionaryapi

Usage


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents the dictionary api client.

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient returns a instance of Client with the default settings. These settings can be optionally modified using ClientOptions that can be passed to NewClient.

type ClientOption

type ClientOption func(*Client)

ClientOption are additional settings that can be passed to the Client.

func WithHTTPClient

func WithHTTPClient(httpClient *resty.Client) ClientOption

WithHTTPClient can be used as a ClientOption to pass a custom httpClient.

func WithWordsManager

func WithWordsManager(wm WordsManager) ClientOption

WithWordsManager can be used as a ClientIOption to pass a custom implementation of the WordsManage interface.

type Definitions

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

Definitions represent a statement of the exact meaning of the Word.

type Error

type Error struct {
	Title      string `json:"title"`
	Message    string `json:"message"`
	StatusCode int    `json:"statusCode"`
	Resolution string `json:"resolution"`
}

Error represents the error returned by the dictionary api.

type Meanings

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

Meanings represents the different meanings of the Word

type Phonetics

type Phonetics struct {
	Text  string `json:"text"`
	Audio string `json:"audio,omitempty"`
}

Phonetics represents the sound of the Word.

type Word

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

Word represents a Word who's meaning is fetched from the dictionary API.

type WordsManager

type WordsManager interface {
	Get(string) (*Word, *errors.RestErr)
}

Jump to

Keyboard shortcuts

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