You are supposed to set up a .env file at the root of this project. That file's gonna be used to configure your database among other stuff. Here it is an example of such a file. Don't forget to change those default configurations.
POSTGRES_HOST="localhost"
POSTGRES_PASSWORD="root"
POSTGRES_PORT=5432
POSTGRES_USER="postgres"
POSTGRES_PASSWORD="root"
POSTGRES_DB_NAME="users"
I've made a docker-compose file for creating a simple postgres databse container for you. To use it, just make sure you've got docker and docker-compose installed on your machine. Then run the simple command:
sudo docker-compose up -d
In this project, i have used the gorm framework to deal with the migrations. So, you don't need to worry about it, it will create the tables automatically when you run the program.
After a few seconds, your container should be up and running. The default database is users and the default password, root. You can change them to whatever you want later!
In order to run this project, make sure you have got golang properly installed on your machine, then run the command at the root of the project
go run ./src/main/main.go
You can easily generate your api route docs. First of all, you're supposed to run the command below, make sure you've got npx on your machine.
npx insomnia-documenter --config ./golang-api.json
Then, you can run a server with your brand new doc by using:
npx serve
Now it's as simple as opening a new tab on your favourite browser and access the link: