Postgres + Go + Docker-compose Can't ping database: dial tcp 127.0.0.1:5432: connect: connection refused

Issue It is not my golang script, but i should to use them in this task: package main import ( "database/sql" "fmt" _ "github.com/lib/pq" "log" "net/http" "github.com/caarlos0/env" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) type config struct { PostgresUri string `env:"POSTGRES_URI" envDefault:"postgres://root:pass@127.0.0.1/postgres"` ListenAddress string

Continue reading

Can't build Golang in dockerfile

Issue I have this structure of my project: https://i.stack.imgur.com/SqqDh.png And this is my Dockerfile: FROM golang:1.19 ADD . /go/src/myapp WORKDIR /go/src/myapp RUN go mod init cloudmeta RUN go get github.com/go-sql-driver/mysql RUN go get -u github.com/gin-gonic/gin RUN go build -o bin/cloudmeta

Continue reading