diff options
Diffstat (limited to 'src/pkg/strconv/atob.go')
-rw-r--r-- | src/pkg/strconv/atob.go | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/pkg/strconv/atob.go b/src/pkg/strconv/atob.go index 98ce75079..d0cb09721 100644 --- a/src/pkg/strconv/atob.go +++ b/src/pkg/strconv/atob.go @@ -4,25 +4,32 @@ package strconv -import "os" - -// Atob returns the boolean value represented by the string. +// ParseBool returns the boolean value represented by the string. // It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. // Any other value returns an error. -func Atob(str string) (value bool, err os.Error) { +func ParseBool(str string) (value bool, err error) { switch str { case "1", "t", "T", "true", "TRUE", "True": return true, nil case "0", "f", "F", "false", "FALSE", "False": return false, nil } - return false, &NumError{str, os.EINVAL} + return false, syntaxError("ParseBool", str) } -// Btoa returns "true" or "false" according to the value of the boolean argument -func Btoa(b bool) string { +// FormatBool returns "true" or "false" according to the value of b +func FormatBool(b bool) string { if b { return "true" } return "false" } + +// AppendBool appends "true" or "false", according to the value of b, +// to dst and returns the extended buffer. +func AppendBool(dst []byte, b bool) []byte { + if b { + return append(dst, "true"...) + } + return append(dst, "false"...) +} |