This is a simple RESTful API Go project that uses Gofr framework and provides the CRUD operations for managing a hospital.
These instructions will help you to clone the repository of the project up and running on your host machine for development and testing purposes.
You need to have Go installed on your machine. You can download it from the official website. You need to have Docker Desktop installed on your machine.
To install the project, follow these steps:
- Clone the repository: git clone (https://github.com/arpit2k2gen/hospi.git)
- Navigate to the project directory: cd gofr
- Initailize the project by command
go mod init gofr
. - Run the command
go mod tidy
. - Two files
go.sum
andgo.mod
would be created. - Download the dependencies:
go get .
- Run the following commands in a terminal to create a table in MySQL docker image
docker run --name gofr-mysql -e MYSQL_ROOT_PASSWORD=root123 -e MYSQL_DATABASE=hospi -p 3306:3306 -d mysql:8.0.30
docker exec -it gofr-mysql mysql -uroot -proot123 hospi -e "CREATE TABLE CREATE TABLE Patients (PatientID INT AUTO_INCREMENT PRIMARY KEY,
Name VARCHAR(255) NOT NULL, Gender VARCHAR(10) NOT NULL,RoomNumber INT NOT NULL, Diagnosis VARCHAR(255) NOT NULL);
To run the tests, use the following command: go test .
or simply click on
just above the test code in
main_test.go
To start the application, use the following command: go run .
or go run main.go
The application will start and listen on port 8000.
GET/patient/{id}
: Get a details of the patient by id.POST/patient
: Create the details of new patient.PUT/patient/{id}
: Update the details of a patient from the list.DELETE/patient/{id}
: Delete the details for a patient.
- Arpit Kaushal - Developer - arpit2k2gen