diff --git a/children.go b/children.go index 81c48a3..712a809 100644 --- a/children.go +++ b/children.go @@ -1,6 +1,6 @@ package main type Child struct { - Name string - Money int + Name string + Money int } diff --git a/db.go b/db.go index 503530b..4f3cc9e 100644 --- a/db.go +++ b/db.go @@ -54,8 +54,8 @@ func check_password(filename, attempt string) (result bool) { } func loadChildren(filename string) (children []Child) { - dbMutex.RLock() - defer dbMutex.RUnlock() + dbMutex.RLock() + defer dbMutex.RUnlock() b, err := ioutil.ReadFile(filename) if err != nil { log.Fatal(err) diff --git a/handlers.go b/handlers.go index fd57fc2..bd3f901 100644 --- a/handlers.go +++ b/handlers.go @@ -9,10 +9,11 @@ func homeHandler(w http.ResponseWriter, req *http.Request) { loggedIn := session.Values["logged in"] if loggedIn == nil { http.Redirect(w, req, "/login", http.StatusSeeOther) + return } - children := loadChildren(*db_file) + children := loadChildren(*db_file) T("index.html").Execute(w, map[string]interface{}{ - "children": children,}) + "children": children}) } func loginHandler(w http.ResponseWriter, req *http.Request) {