|
|
|
@@ -18,6 +18,7 @@ import ( |
|
|
|
"path/filepath" |
|
|
|
"regexp" |
|
|
|
"runtime" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
texttmpl "text/template" |
|
|
|
"time" |
|
|
|
@@ -327,6 +328,7 @@ func NewFuncMap() []template.FuncMap { |
|
|
|
}, |
|
|
|
"GetRefType": GetRefType, |
|
|
|
"GetRefName": GetRefName, |
|
|
|
"MB2GB": MB2GB, |
|
|
|
}} |
|
|
|
} |
|
|
|
|
|
|
|
@@ -785,3 +787,14 @@ func GetRefName(ref string) string { |
|
|
|
reg := regexp.MustCompile(REF_TYPE_PATTERN) |
|
|
|
return reg.ReplaceAllString(ref, "") |
|
|
|
} |
|
|
|
|
|
|
|
func MB2GB(size int64) string { |
|
|
|
s := strconv.FormatFloat(float64(size)/float64(1024), 'f', 2, 64) |
|
|
|
for strings.HasSuffix(s, "0") { |
|
|
|
s = strings.TrimSuffix(s, "0") |
|
|
|
} |
|
|
|
if strings.HasSuffix(s, ".") { |
|
|
|
s = strings.TrimSuffix(s, ".") |
|
|
|
} |
|
|
|
return s |
|
|
|
} |