This is a basic RESTful API built using Go and the Fiber web framework. It provides CRUD operations for managing blog posts using an in-memory fake database (slice of structs).
- Add a new post
- Edit an existing post
- Get all posts
- Get a post by ID
- Delete a post
.
โโโ main.go # Main application file
โโโ go.mod # Go module definition
โโโ README.md # This file
git clone https://github.com/yourusername/your-repo-name.git
cd your-repo-namego mod init github.com/yourusername/your-repo-namego get github.com/gofiber/fiber/v2go run main.goServer will start on http://localhost:8080
| Method | Endpoint | Description |
|---|---|---|
| POST | /posts |
Create a new post |
| PUT | /posts/:id |
Update a post by ID |
| DELETE | /posts/:id |
Delete a post by ID |
| GET | /posts |
Get all posts |
| GET | /posts/:id |
Get a specific post |
{
"id": 1,
"author": "Jane Doe",
"title": "My First Post",
"content": "This is the content of the post."
}- This app uses an in-memory slice to store posts โ data is lost on server restart.
- This is intended for learning and prototyping. For production use, integrate a proper database (PostgreSQL, MongoDB, etc.)
- Add persistent storage (e.g., PostgreSQL)
- Add request validation
- Add Swagger/OpenAPI docs
- Add tests using Go's
testingpackage
Pull requests are welcome. For major changes, please open an issue first to discuss what youโd like to change.
This project is open source and available under the MIT License.