aboutsummaryrefslogtreecommitdiff
path: root/util.go
diff options
context:
space:
mode:
Diffstat (limited to 'util.go')
-rw-r--r--util.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/util.go b/util.go
index 6381bff..55077b8 100644
--- a/util.go
+++ b/util.go
@@ -5,6 +5,7 @@ import (
"html/template"
"log"
"net/http"
+ "strconv"
)
func reloadTemplate(t **template.Template, files ...string) error {
@@ -23,3 +24,12 @@ func templateError(err error, w http.ResponseWriter) {
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
+}