A REST API for managing tasks, built with Go. Create an account, authenticate, and manage personal tasks with CRUD (create, read, update, and delete) operations.
- User registration and JWT authentication
- Create, list, update, and delete tasks
- Local persistence with SQLite and GORM
- Automated controller tests
The project follows an MVC-style architecture, separating responsibilities across models (data structures), controllers (HTTP request handling and application flow), and views (JSON response formatting). Repositories isolate data access from the controllers.
Go · Gin · GORM · SQLite · JWT
- Go 1.27 or later
-
Clone the repository and navigate to the project directory.
-
Create a
.envfile in the project root with a secret used to sign tokens:JWT_SECRET=replace-with-a-strong-secret
-
Download dependencies and start the API:
go mod download go run .
The API will be available at http://localhost:8080. The SQLite database (database.db) and its tables are created automatically on the first run.
| Method | Route | Access | Description |
|---|---|---|---|
POST |
/sign-up |
Public | Register a user |
POST |
/login |
Public | Authenticate and receive an access token |
GET |
/tasks |
Authenticated | List the user's tasks |
POST |
/tasks |
Authenticated | Create a task |
PATCH |
/tasks/:id |
Authenticated | Update a task |
DELETE |
/tasks/:id |
Authenticated | Delete a task |
Task endpoints require a JWT in the Authorization header, using the Bearer <token> format. Access tokens expire after 15 minutes.
Run the controller tests with:
go test github/giovanifz/todolist-go/controllers/testsrequests.http includes examples for registration, login, and task operations. Run them with an HTTP client extension, such as the VS Code REST Client.