To set up the Task Management API project, follow these steps:
- Go: Ensure you have Go installed (version 1.20 or higher is recommended). You can download it from the official Go website.
- PostgreSQL: Install PostgreSQL for database management. Make sure to set up a database for the application.
- Git: Install Git for version control.
-
Clone the Repository: Open your terminal and run the following command to clone the repository:
git clone https://github.com/yourusername/task-management-api.git
-
Navigate to the Project Directory: Change to the project directory:
cd task-management-api
-
Initialize Go Modules: Initialize a new Go module (if not done already):
go mod init task_management_api
-
Install Gin Framework: Install the Gin framework by running:
go get -u github.com/gin-gonic/gin
-
Install GORM and PostgreSQL Driver: Run the following commands to install GORM and the PostgreSQL driver:
go get -u gorm.io/gorm go get -u gorm.io/driver/postgres
-
Configure Environment Variables: Create a
.env
file in the root directory to store your environment variables. Here's an example configuration:DB_USER=your_db_user DB_PASSWORD=your_db_password DB_HOST=localhost DB_PORT=5432 DB_NAME=your_db_name JWT_SECRET=your_jwt_secret
-
Run Migrations: Ensure your database is set up correctly and run any migrations if you have defined them in your application.
-
Start the Application: You can start the application by running:
go run cmd/main.go
-
Access the API: Once the server is running, you can access the API at
http://localhost:8080
.
After setting up, you can test the API using tools like Postman or cURL to ensure the endpoints are functioning correctly.