error connecting to database with mysqldriver

You might want to specify the protocol (like 'tcp'), instead of localhost directly.
See those examples:

user:password@tcp(localhost:5555)/dbname

In your case:

username@tcp(localhost)/my_db

Note, if you use the default protocol (tcp) and host (localhost:3306), this could be rewritten as

user:password@/dbname

I had the same problem and the most voted answer couldn't help me. What saved me was putting (host:port) inside quotation --> "(host:port)"

Tags:

Mysql

Go