DEV Community

Cover image for Create a CRUD app with Go Fiber, docker, and Postgres

Create a CRUD app with Go Fiber, docker, and Postgres

Div Rhino on February 15, 2023

Introduction CRUD refers to the four basic operations an app should be able to perform. The acronym represents the Create, Read, Upd...
Collapse
 
maury_zr profile image
Mauricio Zabala

Hello, thanks for the tutorial, one question?, I don't know why air doesn't work for me when I edit and save a view, it doesn't reload the page in the browser, thanks.

Collapse
 
divrhino profile image
Div Rhino

Hi there! Are you able to see your changes when you refresh the browser? Air rebuilds your project, but it doesn't do hot reloading of the browser, so you still need to manually refresh it.

Collapse
 
maury_zr profile image
Mauricio Zabala

hello, thanks for answering, looking at the console, it only shows the actions with the database but does not rebuild the main.go when save the go file:

Image description

Thread Thread
 
divrhino profile image
Div Rhino

Hello! Would you be able to share the contents of your Dockerfile and docker-compose.yml files?

Thread Thread
 
maury_zr profile image
Mauricio Zabala

Image description

Image description

Thread Thread
 
divrhino profile image
Div Rhino

Hmmm, those files seem like they're all set up correctly. Is your air.toml pointing to your cmd directory?

Thread Thread
 
divrhino profile image
Div Rhino

Hello there. After a bit of googling, it appears that there are others also facing this issue when using Windows. Hoping this gets fixed soon.

Thread Thread
 
divrhino profile image
Div Rhino

Also found another thread in the repo issues that describes a potential fix:
github.com/cosmtrek/air/issues/190...

Collapse
 
maury_zr profile image
Mauricio Zabala

hello, another question, i cant connect to postgress database from navicat:

Image description

Collapse
 
divrhino profile image
Div Rhino

Hello there, sorry to hear that you're having trouble with this.

Here are a few things I would check:

First, the error seems to be indicating that the password is not correct? The tutorial is using divrhinotrivia. In your screenshot it looks like you are also using this value, but maybe it's worth checking again in case there was a typo.

Next, all these values for your connection should match up with the values you have in your .env file as well.

And lastly, your container should be running. You can get it going by running docker compose up.

Collapse
 
maury_zr profile image
Mauricio Zabala

Hello, thanks for answering, I have copied and pasted the values ​​of the env file in the navicat but it keeps giving me a connection error, I have tried restarting the server but it still does not connect externally, I tried with pgAdmin and the same error.

Image description

Thread Thread
 
divrhino profile image
Div Rhino

Hi there, are you able to use the UI to perform any CRUD actions?

Thread Thread
 
maury_zr profile image
Mauricio Zabala

Yes, the UI works correctly, the crud are ok

Thread Thread
 
maury_zr profile image
Mauricio Zabala

is only the remote conection to the database host

Thread Thread
 
maury_zr profile image
Mauricio Zabala

Thanks!