Golang strconv.AppendBool() function example

package strconv

Golang strconv.AppendBool() function usage example.

NOTE : Useful in cases where you evaluate the type in select case statement and append the boolean value into the returning slice or array.

 package main

 import (
 "fmt"
 "strconv"
 )

 func main() {
  dst := []byte("what is ")
  
  fmt.Println("Before : ", string(dst))
  
  b := strconv.AppendBool(dst, true)
  
  fmt.Println("After : ", string(b))
  
 }

Output :

Before : what is

After : what is true

Reference :

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

Advertisement