...
Source file
src/strconv/atob.go
Documentation: strconv
1
2
3
4
5 package strconv
6
7
8
9
10 func ParseBool(str string) (bool, error) {
11 switch str {
12 case "1", "t", "T", "true", "TRUE", "True":
13 return true, nil
14 case "0", "f", "F", "false", "FALSE", "False":
15 return false, nil
16 }
17 return false, syntaxError("ParseBool", str)
18 }
19
20
21 func FormatBool(b bool) string {
22 if b {
23 return "true"
24 }
25 return "false"
26 }
27
28
29
30 func AppendBool(dst []byte, b bool) []byte {
31 if b {
32 return append(dst, "true"...)
33 }
34 return append(dst, "false"...)
35 }
36
View as plain text