We will use RestAPI with Gin Gonic for this project.
- You have PostgreSQL in your computer or you can use the cloud instead.
- For this project, we will need some packages. The dependencies that you need:
go get -u github.com/gin-gonic/gin
go get github.com/lib/pq
go get github.com/joho/godotenv
- Gin is one of frameworks that most used in Go.
- PQ is package that required to
connect Go to PostgreSQL database
- Godotenv is package to read the
.env
file
- You can clone this project.
- You have to make database
recordings
in the postgres. Run this to terminal:psql -U postgres postgres=# CREATE database recordings; postgres=# exit
- Then you can import this sql file to database with running this command:
psql -d recordings -f recordings.sql
- Or you can run manually to create database, create table, and insert data with
DBeaver
,PGAdmin
, and so on. - You can run:
to install the dependencies.
go mod tidy
- And finally, you can run with
go run main.go
- You can just run the handler that do you want in
main.go
. - For documentations, you can import
postman-docs/Edspert.postman_collection.json
file to your Postman if you want to test the API.
- You can clone this project.
- Run this command to build docker image:
docker build -t [image_name] .
- Run the image into container
docker run -p 4000:4000 [image_name]
- You can clone this project.
- Run this command to run docker compose:
docker-compose up
- You have create table in Postgres (in docker) with syntax in
recordings.sql
. The postgres in docker you can access withPGAdmin, DBeaver, so on
withusername: root
,password: secret
,port: 5433
,host:localhost
. - And you can import
postman-docs/Edspert.postman_collection.json
file to your Postman if you want to test the API. - If you want to stop the application, you just need to run:
docker-compose stop