I have to say I don't understand what you are writing about that Ubuntu. Also you have installed Docker Desktop... now?
Just run the databases with those commands. Make sure they are running aand accessible. The open the Go project in Goland (for example) and run it.
Maybe you are trying to write you are trying to run the Go program from Docker? If so, maybe here lies the problem, because from the point of view of the program running in Docker, the localhost (or 127.0.0.1) is the running Docker container itself. And also for database running in the different container, the localhost, from this container point of view, is the container itself.
But if you run the program on your native PC, outside of Docker, all Docker containers are accessible as running on localhost.