This project demonstrates a REST API implementation for managing items, written in Golang. It includes endpoints for CRUD operations and other functionalities for evaluating candidates during interviews.
- CRUD operations for items
- RESTful API design
- Get list items with pagination
- Input validation
- Modular and scalable project structure
- Search and filter items (name, price range)
- Sorting items
- Cache result of each request for 60 seconds
http://localhost:3000
- POST
/items
- Request Body:
[ { "name": "string", "price": number "amount": number } ]
- Response:
[ { "id": "string", "name": "string", "price": number, "amount": number } ]
- GET
/items
- Response:
[ { "id": "string", "name": "string", "price": number, "amount": number } ]
- GET
/items/:id
- Response:
{ "id": "string", "name": "string", "price": number, "amount": number }
- PUT
/items/:id
- Request Body:
{ "name": "string", "price": number, "amount": number }
- Response:
{ "id": "string", "name": "string", "price": number, "amount": number }
- DELETE
/items/:id
- Response:
{ "message": "Item deleted successfully" }
swe-interview-go/
├── data/ # Directory for mount to docker
├── main.go # Entry point
├── .env # env for database connection
├── docker-compose.yaml # Docker for PostgreSQL
├── go.mod # Dependencies
└── README.md # Instructions for candidates
Ensure you have the following installed:
- Golang (>=1.20.x)
-
Clone the repository:
git clone https://github.com/your-repo/swe-interview-go.git cd swe-interview-go
-
Install dependencies:
go get
-
Run PostgreSQL Local:
mkdir data docker-compose up -d
-
Run the project:
go run main.go
-
Access the API at
http://localhost:3000
.