9951 explained code solutions for 126 technologies


golangHow to format string with a boolean


package main
import "fmt"

func main() {
  res := fmt.Sprintf("%t is bool", true)
  fmt.Println(res)
}ctrl + c
package main

default package declaration

import "fmt"

loads fmt package to operate on strings (and print them)

fmt.Sprintf(

formats given string based on a given template and return result

%t

placeholder will return true or false based on a given boolean value

true

sample boolean value to format