Golang strconv.ParseBool() function example

package strconv

Golang strconv.ParseBool() function usage example.

 package main

 import (
  "fmt"
  "strconv"
 )

 func main() {
  str := "1"
  value, err := strconv.ParseBool(str)

  if err != nil {
 fmt.Println(err)
  }

  fmt.Println(value)

 }

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.

Reference :

http://golang.org/pkg/strconv/#ParseBool

Advertisement