# README
Problem Description:
You are tasked with creating a Go application that manages a simple employee database or in-memory store. Additionally, you need to implement a RESTful API with pagination for listing employee records.
Requirements:
- Employee Struct:
-
Define a struct named
Employee
with the following fields: -
ID
(int): Unique identifier for the employee. -
Name
(string): Name of the employee. -
Position
(string): Position/title of the employee. -
Salary
(float64): Salary of the employee.
- CRUD Operations:
-
Implement functions/methods to perform CRUD operations on the employee database or in-memory store:
-
CreateEmployee
: Adds a new employee to the database or store. -
GetEmployeeByID
: Retrieves an employee from the database or store by ID. -
UpdateEmployee
: Updates the details of an existing employee. -
DeleteEmployee
: Deletes an employee from the database or store by ID.
- Concurrency:
- Ensure that the application is safe for concurrent use by using appropriate synchronization mechanisms.
- Testing:
- Write unit tests to cover the CRUD operations and ensure the correctness of the implementation.
- RESTful API with Pagination:
-
Implement a RESTful API for listing employee records with pagination.
-
The API should provide endpoints for listing employees with support for pagination.
-
Each page should contain a configurable number of records.
-
Implement proper error handling and response formatting for the API endpoints
Updated
1. Added Mux and Gin
2. Added Air for auto live reload on save
Updated 2
1. Used Mongo DB for Gin apis
2. Create Docker setup
Setup - Auto Reloading Server
- Clone repo and run
go mod tidy
- complete air setup by following this -
https://github.com/cosmtrek/air
- run
air
in project root directory
Setup - Manaul Server Update
- Clone repo and run
go mod tidy
- run
go run main.go
in project root directory
Setup - using Docker local build
- Clone repo and install docker
- Run
docker-compose up --build