blob: 55077b87bed013c802ca47137e96bf3a830c2df5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package main
import (
"fmt"
"html/template"
"log"
"net/http"
"strconv"
)
func reloadTemplate(t **template.Template, files ...string) error {
tmpl, err := template.ParseFiles(files...)
if err != nil {
msg := fmt.Sprintf("Template load error: %v", err)
log.Println(msg)
} else {
*t = tmpl
}
return err
}
func templateError(err error, w http.ResponseWriter) {
msg := "Template execution error"
http.Error(w, msg, http.StatusInternalServerError)
log.Println(msg)
}
func AtoiOrZero(s string) int {
i, err := strconv.Atoi(s)
if err != nil {
return 0
}
return i
}
|