Golang连接到docker连接到我的SQL docker getsockopt:连接被拒绝

I am loosing my mind trying to set up my golang and docker env. I am using docker compose which seems to book both images fine but when I try run and go lang operations I get an error.

The spacing in your yaml file is important, your mysql line should line up with your app line.

You have to add a

links:
  - mysql

line in under your app: section so it knows to connect the two.

Look here https://github.com/gpuenteallott/golang-mysql-docker-setup/blob/master/docker-compose.yml for a decent working example.