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 maindefault package declaration | import "fmt"loads  | 
| fmt.Sprintf(formats given string based on a given template and return result | %tplaceholder will return  | 
| truesample boolean value to format | |
Usage example
package main
import "fmt"
func main() {
  res := fmt.Sprintf("%t is bool", true)
  fmt.Println(res)
}output
true is bool
More of Golang
- How to print new line with printf()
- Unrmarshal example
- Marshal example
- How to iterate over a slice in reverse order
- How to make POST (form data) request using HTTP client
- How to use proxy with HTTP client
- Find the nameserver records of a domain name
- How to set user agent for HTTP request
- How to format time with milliseconds
- How to sleep for 500 milliseconds
See more codes...