This is a basic CRUD API built with Go and Gin framework. It provides endpoints to create, read, update and delete posts.
To run the API, you will need to have Golang and a PostgreSQL database installed on your machine. You will also need to create a .env
file with your database credentials.
- Clone the repository:
git clone https://github.com/shrine2000/go-crud.git
- Install dependencies:
go mod download
- Create a
.env
file with your database credentials - Run the application:
go run main.go
The API will be available at http://localhost:8080
.
POST /posts
- creates a new post with a title and bodyGET /posts
- retrieves a list of all postsGET /posts/:id
- retrieves a single post by its IDPUT /posts/:id
- updates a post by its IDDELETE /posts/:id
- deletes a post by its ID
The API endpoints can be tested using the included Postman configuration file located at go-crud/postman/Post.postman_collection.json
. Import this file into your Postman application and use it to test the API endpoints.
If you would like to contribute to this project, please fork the repository and submit a pull request.
This project is licensed under the MIT License.