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"
"fmt"
"html/template"
"io/ioutil"
"net/url"
"reflect"
"strconv"
@ -22,6 +23,7 @@ const (
var (
funcMap = template.FuncMap{
"version": version,
"toInt": toInt,
"isResponseIn": isResponseIn,
"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 {
return int(value)
}