Consider a scenario where an employee has left the organization and you want to revoke their details from the database. In that case, we can use the SQL DELETE statement, which we will be covering in this recipe.
Deleting your first record from MySQL
How to do it...
- Install the github.com/go-sql-driver/mysql and github.com/gorilla/mux packages, using the go get command, as follows:
$ go get github.com/go-sql-driver/mysql
$ go get github.com/gorilla/mux
- Create delete-record-mysql.go. Then we connect to the MySQL database, delete the name of an employee from the database, and write the number of records deleted from a database to an HTTP response stream, as follows:
package main
import
(
"database/sql"
"fmt...