This is a simple RESTful API written in Go that uses the Gorilla Mux router and MySQL database to perform CRUD operations on a collection of products.
-
Clone the repository:
https://github.com/Nehul-Krushna/golang_crud_rest_api.git cd golang_crud_rest_api -
Install dependencies:
go mod tidy
-
Set up MySQL:
- Make sure you have MySQL installed and running on your system.
- Create a MySQL database and adjust the connection string in
main.goaccordingly.
-
Run the application:
go run main.go
- GET
/products: Get all products. - GET
/products/{id}: Get a specific product by ID. - POST
/products: Create a new product. - PUT
/products/{id}: Update an existing product. - DELETE
/products/{id}: Delete a product.
{
"id": 1,
"code": "P123",
"price": 100
}