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"
|
"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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue