Gator
🇧🇷 Português | 🇺🇸 English
🇧🇷 Português
Gator é um agregador de feeds RSS de linha de comando escrito em Go.
Descrição
O Gator é um agregador de feeds RSS executado diretamente no terminal. Desenvolvido em Go, o projeto permite que usuários se registrem, sigam múltiplos feeds e visualizem postagens de forma centralizada.
[!NOTE]
Este README foi gerado com a ajuda do Gemini CLI, mas o código fonte é totalmente artesanal e gourmet! :)
Este é um projeto de estudo desenvolvido como parte da trilha de aprendizado de Backend do Boot.dev. O objetivo principal é consolidar conhecimentos em:
- Desenvolvimento de aplicações CLI em Go.
- Integração com bancos de dados relacionais (PostgreSQL).
- Manipulação de concorrência e tarefas agendadas.
- Consumo e processamento de XML/RSS.
Requisitos
Para rodar e desenvolver este projeto, você precisará de:
- Go: Versão 1.25.7 ou superior.
- PostgreSQL: Banco de dados principal para persistência de dados.
- SQLite: Utilizado apenas em memória para execução dos testes automatizados. O projeto usa um driver puramente em Go (
modernc.org/sqlite), portanto não é necessário instalar o SQLite no seu sistema.
- Goose CLI: Necessário para aplicar as migrações no banco de dados PostgreSQL. Embora o projeto utilize a biblioteca Goose internamente para configurar o banco de testes, a aplicação das migrações no banco de produção/desenvolvimento deve ser feita via linha de comando.
- SQLC: Opcional, utilizado para gerar o código Go a partir das queries SQL.
Instalação
Siga os passos abaixo para instalar o Gator:
-
Clone o repositório:
git clone https://github.com/Dhinihan/gator.git
cd gator
-
Compile o binário:
Instale o Gator globalmente em sua máquina usando o comando:
go install github.com/Dhinihan/gator@latest
Isso permitirá que você execute o comando gator diretamente do terminal.
-
Aplique as migrações do banco de dados:
Certifique-se de que seu PostgreSQL está rodando e use o Goose para configurar as tabelas necessárias:
cd sql/schema
goose postgres "postgres://usuario:senha@localhost:5432/nome_do_banco?sslmode=disable" up
Configuração
O Gator utiliza um arquivo de configuração JSON localizado na sua pasta home (~/.gatorconfig.json).
-
Crie o arquivo de configuração:
Crie o arquivo ~/.gatorconfig.json com o seguinte formato:
{
"db_url": "postgres://usuario:senha@localhost:5432/nome_do_banco?sslmode=disable",
"current_user_name": ""
}
Substitua usuario, senha, localhost:5432 e nome_do_banco pelas credenciais do seu banco PostgreSQL.
-
Verifique a conexão:
Tente rodar um comando simples para garantir que tudo está configurado corretamente:
gator users
Uso
O Gator possui diversos comandos para gerenciar feeds e usuários. O formato básico é:
gator <comando> [argumentos]
Comandos Principais:
Desenvolvimento
Para contribuir ou testar o projeto localmente:
-
Executar testes:
O projeto utiliza SQLite em memória para testes, garantindo rapidez e isolamento:
go test ./...
-
Gerar código com SQLC:
Se você alterar os arquivos .sql em sql/queries/, precisará regenerar o código Go:
sqlc generate
Licença
Este projeto está sob a licença Unlicense, tornando-o livre e de domínio público.
🇺🇸 English
Gator is a command-line RSS feed aggregator written in Go.
Description
Gator is an RSS feed aggregator that runs directly in your terminal. Developed in Go, the project allows users to register, follow multiple feeds, and view posts in a centralized manner.
[!NOTE]
This README was generated with the help of Gemini CLI, but the source code is entirely handcrafted and gourmet! :)
This is a study project developed as part of the Backend learning path from Boot.dev. The main goal is to consolidate knowledge in:
- Developing CLI applications in Go.
- Integrating with relational databases (PostgreSQL).
- Handling concurrency and scheduled tasks.
- Consuming and processing XML/RSS.
Requirements
To run and develop this project, you will need:
- Go: Version 1.25.7 or higher.
- PostgreSQL: Main database for data persistence.
- SQLite: Used only in memory for running automated tests. The project uses a pure Go driver (
modernc.org/sqlite), so no system-wide SQLite installation is required.
- Goose CLI: Required to apply migrations to the PostgreSQL database. While the project uses the Goose library internally for the test database, applying migrations to the production/development database must be done via the command line.
- SQLC: Optional, used to generate Go code from SQL queries.
Installation
Follow the steps below to install Gator:
-
Clone the repository:
git clone https://github.com/Dhinihan/gator.git
cd gator
-
Build the binary:
Install Gator globally on your machine using the command:
go install github.com/Dhinihan/gator@latest
This will allow you to run the gator command directly from your terminal.
-
Apply database migrations:
Ensure your PostgreSQL is running and use Goose to set up the necessary tables:
cd sql/schema
goose postgres "postgres://user:password@localhost:5432/db_name?sslmode=disable" up
Configuration
Gator uses a JSON configuration file located in your home folder (~/.gatorconfig.json).
-
Create the configuration file:
Create the file ~/.gatorconfig.json with the following format:
{
"db_url": "postgres://user:password@localhost:5432/db_name?sslmode=disable",
"current_user_name": ""
}
Replace user, password, localhost:5432, and db_name with your PostgreSQL credentials.
-
Verify connection:
Try running a simple command to ensure everything is set up correctly:
gator users
Usage
Gator has several commands to manage feeds and users. The basic format is:
gator <command> [arguments]
Main Commands:
-
Registration and Login:
gator register <name>: Creates a new user and sets them as the current user.
gator login <name>: Changes the current user in the settings.
gator users: Lists all registered users.
-
Feed Management:
gator addfeed <name> <url>: Adds a new RSS feed (requires login).
gator feeds: Lists all feeds added by all users.
gator follow <url>: Starts following an existing feed (requires login).
gator unfollow <url>: Stops following a feed (requires login).
gator following: Lists all feeds you are following.
-
Aggregation and Viewing:
gator agg <interval>: Starts collecting posts from feeds at regular intervals (e.g., 1m, 1h, 30s).
gator browse [limit]: Shows the latest posts from the feeds you follow (default is 2 posts).
-
Administration:
gator reset: Deletes all data from the database (use with caution!).
Development
To contribute or test the project locally:
-
Run tests:
The project uses in-memory SQLite for tests, ensuring speed and isolation:
go test ./...
-
Generate code with SQLC:
If you change the .sql files in sql/queries/, you will need to regenerate the Go code:
sqlc generate
License
This project is under the Unlicense, making it free and public domain.