I have made a REST API using Golang and it connects to MySQL DB present on MySQL Workbench installed locally, now I wish to dockerise this API but how do I connect to external DB in Docker-Compose? I'm new to docker, so have little idea of things.
func dbConnection() (db *sql.DB) {
db, err := sql.Open("mysql", "root:password@tcp(127.0.0.1:3306)/testDB")
if err != nil {
panic(err)
}
return db
}