Coming from NodeJs background, I use this snippet to handle MySQL database connection errors. This npm page has more details. I did come across go-sql-driver/mysql; but, it didn't describe raising and handling events arising out database connections, etc.
How do we build event-driven applications for MySQL client in Go?
connection.on('error', function(err) {
console.log(err.code); // 'ER_BAD_DB_ERROR'
});
connection.query('USE name_of_db_that_does_not_exist');