Consider a scenario where you have created a record for an employee in a database with all its details, such as name, department, address, and so on, and after some time the employee changes departments. In that case, we have to update their department in a database so that their details are in sync all across the organization, which can be achieved using a SQL UPDATE statement, and in this recipe we will learn how we can implement it in Go.
Updating your first record in 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 update-record-mysql.go. Then we connect...