A simple RSS blog aggregator cli written in Go using Postgres SQL as the database.
You can install gator in two ways: (1) from source or (2) using Go directly. Afterwards, you need to set up the database and run migrations using goose.
- Clone the repository:
git clone https://github.com/donaldnguyen99/gator.git
- Change to the project directory:
cd gator - Install the binary (defaults to
$GOPATH/bin or $HOME/go/bin if $GOPATH is not set):go install
- Install the binary directly:
go install github.com/donaldnguyen99/gator@latest
-
Create a connection string like
postgres://username:password@host:port/database. This connection string will be used to connect to your Postgres database. You can set it as an environment variable, which will also be needed to run gator for the first time:export GATOR_POSTGRES_URL="postgres://username:password@host:port/database"
- Replace
username,password,host,port, anddatabasewith your actual system credentials and Postgres host, port, and database name. - Example:
postgres://postgres:postgres@localhost:5432/gator - To create the database, you can use run the
psqlcommand to log into Postgres and create the database namedgator. With the example connection string above without a database name, you can run:psql postgres://postgres:postgres@localhost:5432 CREATE DATABASE gator; exit
- Replace
-
Run goose
goose postgres <connection_string> up
This will run the initial migrations to create the necessary tables.
-
For the first time running gator, make sure the
GATOR_POSTGRES_URLenvironment variable is set to your Postgres connection string.echo $GATOR_POSTGRES_URL
If it is not set, you can set it using
exportfrom the migration step above. -
You will need to register a user to run gator:
gator register <your_name>
After registering, you will be logged in automatically.
-
To login with an existing user:
gator login <your_name>
-
To list users:
gator users
-
To add a blog feed, you need to be logged in. Run:
gator addfeed "Blog Name" <blog_url>
-
To list all blog feeds across all users:
gator feeds
-
To follow a blog feed from another user, you need to be logged in. Run:
gator follow <blog_url>
-
To unfollow a blog feed, you need to be logged in. Run:
gator unfollow <blog_url>
-
To list all blog feeds for the current user:
gator following
-
To aggregate posts from all followed blogs, run the following as a background process or in a separate terminal. The agg command will require a duration argument to specify how long to aggregate posts for. The duration can be in the format of
1h20m30s(1 hour, 20 minutes, and 30 seconds) or1h(1 hour). Minimum duration is 1 second. The maximum duration is 24 hours.gator agg 1h20m30s
-
To list all posts of followed feeds, you need to be logged in. Default number of posts displayed is 2. Run:
gator browse [num_posts]