Standard library / strconv

strconv.AppendBool()

Appends boolean as lowercase text to dst. Returns the expanded slice; retain it even if the initial destination has enough capacity. Expected stdout: 'v=true\n'.

Formal Syntax & Structure

go syntaxgo
func AppendBool(dst []byte, b bool) []byte

Parameters & Attributes

NameTypeDescription
dst[]byteDestination byte slice; existing prefix is preserved.
bboolBoolean value to encode.

Return Value

[]byte

Resulting byte slice, including original prefix.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strconv")
func main() {  b := []byte("v=")  b = strconv.AppendBool(b, true)  fmt.Println(string(b))}
Go Reference