This is a Book Management System based on a tutorial by freeCodeCamp.org
, implemented with Golang and MySQL. This application allows users to manage books by providing CRUD (Create, Read, Update, Delete) operations through a RESTful API.
- Create a new book
- Get all books
- Get book by id
- Update a book
- Delete a book
To install and run this application, follow these steps:
-
Clone this repository to your local machine.
https://github.com/dinethsiriwardana/Book-Management-System-with-Golang-and-Mysql.git
-
Install MySQL and make sure it is running on your machine.
-
Create a new database named
bookstore
. -
Update the MySQL connection string in the
Connect()
function in thepkg/config/app.go
file. -
Build and run the application by executing the following command from the project root directory:
go run cmd/main/main.go
Once the application is running, you can perform CRUD operations on books by sending HTTP requests to the following endpoints:
Endpoint | Method | Description |
---|---|---|
/api/book | GET | Get all books |
/api/book/:id | GET | Get book by id |
/api/book | POST | Create a new book |
/api/book/:id | PUT | Update a book |
/api/book/:id | DELETE | Delete a book |
You can use tools like Postman or cURL to send HTTP requests to the endpoints.
book-management-system/
├── cmd/
│ └── main/
│ └── main.go
└── pkg/
├── config/
│ └── app.go
├── models/
│ └── book.go
├── controllers/
│ └── book-controller.go
├── routes/
│ └── bookstore-routes.go
└── utils/
└── utils.go