August 2016
Beginner to intermediate
665 pages
14h 11m
English
In this section, we'll quickly look at our sample Appointments Calendar application, which attempts to control consistency of specific elements to avoid obvious race conditions. The following is the full code, including the routing and templating:
package main import( "net/http" "html/template" "fmt" "github.com/gorilla/mux" "sync" "strconv" ) type User struct { Name string Times map[int] bool DateHTML template.HTML } type Page struct { Title string Body template.HTML Users map[string] User } var usersInit map[string] bool var userIndex int var validTimes []int var mutex sync.Mutex var Users map[string]User var templates = template.Must(template.New("template").ParseFiles("view_users.html", "register.html")) func ...Read now
Unlock full access