Different Ways to Convert the Boolean Type in String in Golang Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report In order to convert Boolean Type to String type in Golang , you can use the strconv and fmt package function. 1. strconv.FormatBool() Method: The FormatBool is used to Boolean Type to String. It returns "true" or "false" according to the value of b. Syntax: func FormatBool(b bool) string Example : Convert an Boolean Type into String using strconv.FormatBool() function. Go // Go program to illustrate // How to convert the // Boolean Type into String package main import ( "fmt" "strconv" ) //Main Function func main() { i := true s := strconv.FormatBool(i) fmt.Printf("Type : %T \nValue : %v\n", s, s) } Output: Type : string Value : true 2. fmt.Sprintf() Method: The Sprintf is used to represents the string by formatting according to a format specifier. Syntax: func Sprintf(format string, a ...interface{}) string Example : Convert an Boolean Type into String using fmt.Sprintf() function. Go // Go program to illustrate // How to convert the // Boolean Type into String package main import ( "fmt" ) //Main Function func main() { i := true s := fmt.Sprintf("%v", i) fmt.Printf("Type : %T \nValue : %v\n\n", s, s) i1 := false s1 := fmt.Sprintf("%v", i1) fmt.Printf("Type : %T \nValue : %v\n", s1, s1) } Output: Type : string Value : true Type : string Value : false Comment More infoAdvertise with us Next Article Different Ways to Convert the Boolean Type in String in Golang S SHUBHAMSINGH10 Follow Improve Article Tags : Go Language Similar Reads Different Ways to Convert an Integer Variable to String in Golang Integer variable cannot be directly convert into String variable. In order to convert string to integer type in Golang , you have store value of integer variable as string in string variable. For this, we are using strconv and fmt package functions. 1. Itoa() Function:Â The Itoa stands for Integer t 3 min read Different ways to concatenate two strings in Golang In Go, strings are immutable sequences of bytes encoded with UTF-8. Concatenating two or more strings into a single string is straightforward in Go, and there are several ways to accomplish it. In this article,we will learn various ways to concatenate two strings in Golang.ExampleInput:s1 := "Hello, 3 min read Different ways to compare Strings in Golang In Go, strings are immutable sequences of bytes encoded in UTF-8. You can compare them using comparison operators or the strings.Compare function. In this article,we will learn different ways to compare Strings in Golang.Examplepackage main import ( "fmt" "strings" ) func main() { s1 := "Hello" s2 : 2 min read Different Ways to Find the Type of an Object in Golang Go does not have the concept of a class type, therefore, you do not have objects in Go. You can refer any data type in Go as an object. There are several data types provided by Go such as int8, int16, int32, int64, float64, string, bool etc. There are three different ways by which you can find the t 4 min read How to convert a string in uppercase in Golang? In Go, strings are sequences of variable-width characters represented using UTF-8 Encoding. You can convert a string to uppercase using functions from the strings package, which must be imported into your program. In this article we will learn "How to Convert a String to Uppercase in Golang".Example 2 min read Like