![Learn Data Structures and Algorithms with Golang](https://wfqqreader-1252317822.image.myqcloud.com/cover/744/36698744/b_36698744.jpg)
上QQ阅读APP看书,第一时间看更新
The Alter function
The following code shows how the Alter function renders the Home template by invoking the ExecuteTemplate method with the writer and customers arrays as parameters:
// Alter - execute template
func Alter(writer http.ResponseWriter, request *http.Request) {
var customer Customer
var customerId int
var customerIdStr string
customerIdStr = request.FormValue("id")
fmt.Sscanf(customerIdStr, "%d", &customerId)
customer.CustomerId = customerId
customer.CustomerName = request.FormValue("customername")
customer.SSN = request.FormValue("ssn")
UpdateCustomer(customer)
var customers []Customer
customers = GetCustomers()
template_html.ExecuteTemplate(writer,"Home",customers)
}