Welcome to Random Quote! 🚀
This is a simple Go application that fetches and displays a random inspirational quote from either the ZenQuotes API or the Quotable API.
- 📦 Modular Structure: Organized with
cmd,internal/services,internal/model, andinternal/loggerfor maintainability. - 🌐 Live Quotes: Fetches a new random quote from the internet every time you run it.
- 🔄 API Fallback: If one API fails, the app automatically tries the other.
- 💾 Save Quotes: Optionally save quotes to a text file.
- 🧪 Unit Tested: Includes a suite of unit tests with HTTP mocking.
- 🧩 Easy to Extend: Add new services, models, or logging strategies with minimal effort.
Random Quote/
├── cmd/
│ └── main.go # Entry point
├── internal/
│ ├── logger/
│ │ └── logger.go # Error handling
│ ├── model/
│ │ └── model.go # Data models and API URLs
│ └── services/
│ ├── service.go # Quote fetching logic
│ └── service_test.go# Unit tests
├── go.mod # Go module definition
├── .gitignore # Git ignore rules
├── LICENSE # MIT License
└── README.md # This file
-
Clone the repository:
git clone https://github.com/drclcomputers/Random-Quote/ cd random-quote -
Build the application:
go build -o quote ./cmd
-
Run the application:
./quote
Or run directly without building:
go run ./cmd
You can run the app with only one of the following options:
-z: Use the ZenQuotes API.-q: Use the Quotable API.-s: Save the fetched quote to a text file.-h: Show help.
Examples:
./random-quote -z
./random-quote -q
./random-quote -s
./random-quote -hThe only way to do great work is to love what you do.
- Steve Jobs
To run all unit tests (with HTTP mocking):
go test ./internal/servicesContributions are welcome! Please open issues or submit pull requests for improvements.
This project is licensed under the MIT License.
- ZenQuotes API for providing awesome quotes.
- Quotable API for additional quotes.
"Stay inspired. Keep coding!"