Create version template helper

This commit is contained in:
Andrea Fazzi 2020-01-28 08:58:00 +01:00
parent f49236b465
commit 7f07a947a3
2 changed files with 11 additions and 1 deletions

View file

@ -1 +1 @@
0.1.0-3-gf576e74 0.1.0-4-gf49236b

View file

@ -4,6 +4,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"html/template" "html/template"
"io/ioutil"
"net/url" "net/url"
"reflect" "reflect"
"strconv" "strconv"
@ -22,6 +23,7 @@ const (
var ( var (
funcMap = template.FuncMap{ funcMap = template.FuncMap{
"version": version,
"toInt": toInt, "toInt": toInt,
"isResponseIn": isResponseIn, "isResponseIn": isResponseIn,
"query": query, "query": query,
@ -65,6 +67,14 @@ var (
} }
) )
func version() string {
version, err := ioutil.ReadFile("./VERSION")
if err != nil {
return ""
}
return string(version)
}
func toInt(value float64) int { func toInt(value float64) int {
return int(value) return int(value)
} }