Skip to content

Commit 7bd8c96

Browse files
author
Nicolas Rodriguez
committed
Export ParseBool function from strconv to template
btw: the first lines of Go in my life :)
1 parent d235ca2 commit 7bd8c96

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

template.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"os"
1414
"path/filepath"
1515
"reflect"
16+
"strconv"
1617
"strings"
1718
"syscall"
1819
"text/template"
@@ -173,6 +174,10 @@ func hasPrefix(prefix, s string) bool {
173174
return strings.HasPrefix(s, prefix)
174175
}
175176

177+
func parseBool(s string) (bool, error) {
178+
return strconv.ParseBool(s)
179+
}
180+
176181
// hasSuffix returns whether a given string is a suffix of another string
177182
func hasSuffix(suffix, s string) bool {
178183
return strings.HasSuffix(s, suffix)
@@ -346,6 +351,7 @@ func newTemplate(name string) *template.Template {
346351
"keys": keys,
347352
"last": arrayLast,
348353
"replace": strings.Replace,
354+
"parseBool": parseBool,
349355
"parseJson": unmarshalJson,
350356
"queryEscape": url.QueryEscape,
351357
"sha1": hashSha1,

0 commit comments

Comments
 (0)