March 2019
Intermediate to advanced
336 pages
9h 9m
English
The defer statement defers the execution of the function until the surrounding function returns. The panic function stops the current flow and control. Deferred functions are executed normally after the panic call. In the following code example, the defer call gets executed even when the panic call is invoked:
defer database.Close() return customer}// GetCustomers method returns Customer Arrayfunc GetCustomers() []Customer { var database *sql.DB database = GetConnection() var error error var rows *sql.Rows rows, error = database.Query("SELECT * FROM Customer ORDER BY Customerid DESC") if error != nil { panic(error.Error()) } var customer Customer customer = Customer{} var customers []Customer
Read now
Unlock full access