Skip to content

A simple and efficient command-line interface (CLI) tool for fetching word definitions from free dictionary APIs.

License

Notifications You must be signed in to change notification settings

Trynax/Dictionary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dictionary CLI Tool

A command-line dictionary application built in Go that provides word definitions, pronunciations, and examples using the Free Dictionary API.

Features

  • 🔍 Real-time word lookup - Get definitions for any English word
  • 📚 Comprehensive results - Shows definitions, pronunciations, examples, and part of speech
  • Smart caching - Caches results for 5 minutes to improve performance
  • 🔄 Continuous mode - Keep searching without restarting the app
  • 🛡️ Graceful shutdown - Clean exit with Ctrl+C

Installation

Prerequisites

  • Go 1.19 or higher

Build from source

git clone https://github.com/trynax/Dictionary.git
cd Dictionary
make build .

Run directly

make run

Usage

  1. Start the application:

    cmd.exe
  2. Search for words:

    Search for a word... 
    hello
    
    hello /həˈloʊ/
    EXCLAMATION
    1. used as a greeting or to begin a phone conversation
    Example: hello there, Katie!
    
    NOUN
    1. an utterance of 'hello'; a greeting
    Example: she was getting polite nods and hellos from people
    
  3. Exit the application:

    • Press Ctrl+C or close the terminal

API Reference

This application uses the Free Dictionary API to fetch word definitions.

Endpoint: https://api.dictionaryapi.dev/api/v2/entries/en/{word}

Technical Details

Caching

  • Uses sync.Map for thread-safe caching
  • Cache entries expire after 5 minutes
  • Automatic cleanup with goroutines

Error Handling

  • Graceful handling of API failures
  • Network timeout management
  • Invalid word input handling

Performance

  • Concurrent cache cleanup
  • Efficient JSON unmarshaling
  • Minimal memory footprint

Dependencies

  • Standard Library Only - No external dependencies required
  • Uses Go's built-in net/http, encoding/json, and sync packages

Example Output

Search for a word... 
programming

programming /ˈproʊɡræmɪŋ/
NOUN
1. the process or activity of writing computer programs
Example: software programming requires logical thinking

VERB
1. present participle of program
Example: I am programming a new application

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Roadmap

  • Implement word history tracking
  • Add pronunciation audio playback
  • Export definitions to file
  • Add fuzzy search for misspelled words

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Free Dictionary API for providing the word data
  • Go community for excellent documentation and examples

Author

trynax - GitHub Profile


Built with ❤️ using Go

About

A simple and efficient command-line interface (CLI) tool for fetching word definitions from free dictionary APIs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published