fixed leaking info, plus go fmt

This commit is contained in:
Stephen McQuay 2013-03-06 13:31:30 -07:00
parent fe0411e8df
commit 6a62e10c26
3 changed files with 7 additions and 6 deletions

View File

@ -1,6 +1,6 @@
package main package main
type Child struct { type Child struct {
Name string Name string
Money int Money int
} }

4
db.go
View File

@ -54,8 +54,8 @@ func check_password(filename, attempt string) (result bool) {
} }
func loadChildren(filename string) (children []Child) { func loadChildren(filename string) (children []Child) {
dbMutex.RLock() dbMutex.RLock()
defer dbMutex.RUnlock() defer dbMutex.RUnlock()
b, err := ioutil.ReadFile(filename) b, err := ioutil.ReadFile(filename)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)

View File

@ -9,10 +9,11 @@ func homeHandler(w http.ResponseWriter, req *http.Request) {
loggedIn := session.Values["logged in"] loggedIn := session.Values["logged in"]
if loggedIn == nil { if loggedIn == nil {
http.Redirect(w, req, "/login", http.StatusSeeOther) http.Redirect(w, req, "/login", http.StatusSeeOther)
return
} }
children := loadChildren(*db_file) children := loadChildren(*db_file)
T("index.html").Execute(w, map[string]interface{}{ T("index.html").Execute(w, map[string]interface{}{
"children": children,}) "children": children})
} }
func loginHandler(w http.ResponseWriter, req *http.Request) { func loginHandler(w http.ResponseWriter, req *http.Request) {