This is a simple Go application that allows users to track their daily calorie intake. The application uses a PostgreSQL database to store the data. The application is built using the Gin framework.
- PostgreSQL database
- Go 1.21 or later
- Docker
- Clone the repository
git clone https://github.com/Sadeedpv/go-calorie-tracker.git
- Install dependencies
go mod download
- Create a .env file and add your database credentials
DB_URL=postgres://user:password@localhost:5432/calorie_tracker
- Run the application
go run main.go
The application exposes the following endpoints:
-
/v1/calories
: Get all calories -
/v1/calories
: Add a calorie -
/v1/calories
: Delete all calories -
/v1/calories/:id
: Get a calorie by ID -
/v1/calories/:id
: Update a calorie by ID -
/v1/totalcalories
: Get the total number of calories
You can also run the application using Docker.
- Build the image
docker build -t go-calorie-tracker .
- Run the container
docker run -p 8000:8000 go-calorie-tracker
Contributions are welcome! Please open a pull request if you have any suggestions or improvements.