Create version template helper
This commit is contained in:
parent
f49236b465
commit
7f07a947a3
2 changed files with 11 additions and 1 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
0.1.0-3-gf576e74
|
||||
0.1.0-4-gf49236b
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue