Skip to content

Commit

Permalink
Export ParseBool function from strconv to template
Browse files Browse the repository at this point in the history
btw: the first lines of Go in my life :)
  • Loading branch information
Nicolas Rodriguez committed Aug 16, 2015
1 parent d235ca2 commit 7bd8c96
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions template.go
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"path/filepath"
"reflect"
"strconv"
"strings"
"syscall"
"text/template"
Expand Down Expand Up @@ -173,6 +174,10 @@ func hasPrefix(prefix, s string) bool {
return strings.HasPrefix(s, prefix)
}

func parseBool(s string) (bool, error) {
return strconv.ParseBool(s)
}

// hasSuffix returns whether a given string is a suffix of another string
func hasSuffix(suffix, s string) bool {
return strings.HasSuffix(s, suffix)
Expand Down Expand Up @@ -346,6 +351,7 @@ func newTemplate(name string) *template.Template {
"keys": keys,
"last": arrayLast,
"replace": strings.Replace,
"parseBool": parseBool,
"parseJson": unmarshalJson,
"queryEscape": url.QueryEscape,
"sha1": hashSha1,
Expand Down

0 comments on commit 7bd8c96

Please sign in to comment.