A command-line RSS feed aggregator built with Go. Gator allows you to track and browse RSS feeds from your terminal.
Before running this program, you'll need to have the following installed on your system:
- Go (version 1.20 or higher) - Download and install Go
- PostgreSQL - Download and install PostgreSQL
- Goose - Database migration tool
Make sure PostgreSQL is running and you have access to create databases.
Install goose using Go:
go install github.com/pressly/goose/v3/cmd/goose@latestInstall the gator CLI using Go's install command:
go install github.com/khizar-sudo/gator@latestThis will download, compile, and install the gator binary to your $GOPATH/bin directory (or $GOBIN if set).
Make sure your $GOPATH/bin is in your system's PATH to run gator from anywhere:
# Add this to your ~/.bashrc or ~/.zshrc
export PATH=$PATH:$(go env GOPATH)/bin- Create a PostgreSQL database for the feed aggregator:
CREATE DATABASE gator;- Run the database migrations using goose:
cd sql/schema
goose postgres "postgres://username:password@localhost:5432/gator?sslmode=disable" upReplace username and password with your PostgreSQL credentials.
This will automatically run all migration files in the correct order. Goose tracks which migrations have been applied, so it's safe to run this command multiple times.
-
Check migration status:
goose postgres "postgres://username:password@localhost:5432/gator?sslmode=disable" status -
Rollback the last migration:
goose postgres "postgres://username:password@localhost:5432/gator?sslmode=disable" down -
Reset database (rollback all migrations):
goose postgres "postgres://username:password@localhost:5432/gator?sslmode=disable" reset
Before running the program, you need to create a configuration file in your home directory:
File location: ~/.gatorconfig.json
Contents:
{
"db_url": "postgres://username:password@localhost:5432/gator?sslmode=disable",
"current_user_name": ""
}Replace username and password with your PostgreSQL credentials. The current_user_name field will be automatically populated when you register or login.
The general syntax for running commands is:
gator <command> [arguments]-
Register a new user:
gator register <username>
Creates a new user and automatically logs you in.
-
Login as an existing user:
gator login <username>
Sets the current user in the config file.
-
List all users:
gator users
Displays all registered users.
-
Add a new RSS feed:
gator addfeed <feed_name> <feed_url>
Example:
gator addfeed "Blog" https://blog.example.com/feed.xmlThis command automatically follows the feed after adding it.
-
List all feeds:
gator feeds
Shows all RSS feeds in the system and their creators.
-
Follow a feed:
gator follow <feed_url>
Start following an existing feed.
-
List feeds you're following:
gator following
Shows all feeds that you're currently following.
-
Unfollow a feed:
gator unfollow <feed_url>
Stop following a feed.
-
Start the aggregator:
gator agg <time_duration>
Example:
gator agg 1morgator agg 30sFetches new posts from all feeds at the specified interval. This command runs continuously until you stop it (Ctrl+C).
-
Browse recent posts:
gator browse [limit]
Example:
gator browse 10Displays recent posts from feeds you're following. If no limit is specified, it shows 2 posts by default.
- Reset the database:
Deletes all users and cascades to feeds and posts (use with caution!).
gator reset
Here's a typical workflow to get started:
# 1. Register a new user
gator register john
# 2. Add some RSS feeds
gator addfeed "Boot.dev Blog" https://blog.boot.dev/index.xml
gator addfeed "Golang Weekly" https://golangweekly.com/rss
# 3. View all feeds
gator feeds
# 4. Start the aggregator in the background (fetch every minute)
gator agg 1m &
# 5. Browse recent posts
gator browse 5This project uses:
- sqlc for type-safe SQL queries
- goose for database migrations
- PostgreSQL for data storage
- Native Go RSS parsing
This project is part of the Boot.dev curriculum.