Learn Data Structures and Algorithms with Golang
上QQ阅读APP看书,第一时间看更新

CRM web application

The CRM web application is shown as follows, with various web paths handled. The CRM application code is shown in the following code. The Home function executes the Home template with the writer parameter and the customers array (crm_app.go):


//main package has examples shown
// in Hands-On Data Structures and algorithms with Go book
package main

// importing fmt,database/sql, net/http, text/template package
import (
"fmt"
"net/http"
"text/template"
"log"
)


var template_html = template.Must(template.ParseGlob("templates/*"))

// Home - execute Template
func Home(writer http.ResponseWriter, request *http.Request) {
var customers []Customer
customers = GetCustomers()
log.Println(customers)
template_html.ExecuteTemplate(writer,"Home",customers)

}


Let's take a look at the Create, Insert, Alter, Update, and Delete functions, as well as the main method in the following sections.