Please install the following for running OS environment before continue:
- Git clone current repository to your local environment and open with preferred IDE [eg: VS code].
- Rename .env.example to
.env
file . - Make sure
no other application
running at port3000
as it will be used by the application. - Make sure docker is already running at local environment.
- Open terminal in
project root path
and run following command to verify docker are running:
# View installed docker version
docker version
- If docker is not running, please run docker and repeat Step 5.
- At the terminal, run following command to start
containerized RESTful services
in Go with Postgres database via Docker.
# Create docker instance based on docker-compose.yml
docker compose up
-
Make sure terminal have the following prompt below continue:
-
Open Postman and start to send RESTful API with correct parameter as stated in API sesison below.
This API will return the raw JSON format of stored object(s) in Postgres. Hence, it will be empty by default and objects will be displayed after running POST
request for at least once and success.
Sample Response
[
{
"ID": 1,
"CreatedAt": "2022-12-14T14:42:59.162640885Z",
"UpdatedAt": "2022-12-14T14:42:59.162640885Z",
"DeletedAt": null,
"question": "Is this a sample?",
"answer": "Yes"
},
{
"ID": 2,
"CreatedAt": "2022-12-14T14:45:11.451989Z",
"UpdatedAt": "2022-12-14T14:45:11.451989Z",
"DeletedAt": null,
"question": "Is this a sample too?",
"answer": "Yea!"
}
]
Use Postman
and create a new POST request.
Then, choose Body
, then raw
and make sure JSON is selected. Paste in the following skeleton and fill in accordingly.
Body
name | required |
---|---|
question | yes |
answer | yes |
Sample Body
{
"question": "Who learn Golang today?",
"answer": "Me!",
}
Response
{
"ID": 1,
"CreatedAt": "2022-12-14T14:42:59.162640885Z",
"UpdatedAt": "2022-12-14T14:42:59.162640885Z",
"DeletedAt": null,
"question": "Who learn Golang today?",
"answer": "Me!"
}
- Go-fiber
- Gorm with Postgres driver
- Air