1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
7 // ParseBool returns the boolean value represented by the string.
8 // It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False.
9 // Any other value returns an error.
10 func ParseBool(str
string) (value
bool, err error
) {
12 case "1", "t", "T", "true", "TRUE", "True":
14 case "0", "f", "F", "false", "FALSE", "False":
17 return false, syntaxError("ParseBool", str
)
20 // FormatBool returns "true" or "false" according to the value of b
21 func FormatBool(b
bool) string {
28 // AppendBool appends "true" or "false", according to the value of b,
29 // to dst and returns the extended buffer.
30 func AppendBool(dst
[]byte, b
bool) []byte {
32 return append(dst
, "true"...)
34 return append(dst
, "false"...)