Standard library / strconv
strconv.ParseBool()
Accepts exactly 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Other strings return a syntax error. Expected stdout: 'true <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func ParseBool(str string) (bool, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| str | string | Input text to parse, inspect or quote. |
Return Value
(bool, error)
Decoded or parsed value and error; inspect the error before using the result.
Working Example
Example Snippetgo
package main
import ( "fmt" "strconv")
func main() { v, e := strconv.ParseBool("TRUE") fmt.Println(v, e)}