I will add that you can parse out the signal code from the sql state like this:
if mysqlErr, ok := err.(*mysql.MySQLError); ok { code := string(mysqlErr.SQLState[:]) }