I am using the github.com/go-sql-driver/mysql package to interface to mysql. I have the variables that get set coming from a conf file. Each element is a string value.
Have you tried hardcoding your connection string? Does it work then? Is your connection string really assembled as you would expect it to be, or is there something wrong? Does defaulting your config to an empty string make any sense or would erroring be more appropriate on missing config values?
When I copied my parameters that were hardcoded in the go service into the conf file I left the quotes around the fields. These pulled through literally causing 1 problem. Removing them got me past that issue.
I still couldn’t connect though and I was using the root account to test the program. I created a new user account that had access from localhost and now things are working.
So it ended up being a slightly misconfigured mysql and a conf file that was pulling in quotes.