Different Ways to Convert an Integer Variable to String in Golang Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report 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 to ASCII and returns the string representation of integer with base 10. Syntax: func Itoa(i int) string Example : Convert an integer variable into String using strconv.Itoa() function. Go // Go program to illustrate // How to convert integer // variable into String package main import ( "fmt" "strconv" ) //Main Function func main() { i := 32 s := strconv.Itoa(i) fmt.Printf("Type : %T \nValue : %v\n", s, s) } Output: Type : string Value : 32 2. FormatInt() Function: The FormatInt is used to represents the string of integer value with base [2,36]. The result uses the lower-case letters 'a' to 'z' for digit values >= 10. Syntax: func FormatInt(i int64, base int) string Example : Convert an integer variable into String using strconv.FormatInt() function. Go // Go program to illustrate // How to convert integer // variable into String package main import ( "fmt" "strconv" ) //Main Function func main() { i := -32 s := strconv.FormatInt(int64(i) , 7) fmt.Printf("Type : %T \nValue : %v\n", s, s) } Output: Type : string Value : -44 3. FormatUint() Function: The FormatUint is used to represents the string of integer value with base [2,36]. The result uses the lower-case letters 'a' to 'z' for digit values >= 10. It is similar to FormatInt but the difference is that uint64 is the type of integer value. Syntax: func FormatUint(i uint64, base int) string Example : Convert an integer variable into String using strconv.FormatUint() function. Go // Go program to illustrate // How to convert integer // variable into String package main import ( "fmt" "strconv" ) //Main Function func main() { i := 32 s := strconv.FormatUint(uint64(i) , 7) fmt.Printf("Type : %T \nValue : %v\n", s, s) } Output: Type : string Value : 44 4. Sprintf() Function: The Sprintf is used to represents the string of integer value by formatting according to a format specifier and returns the resulting string. Syntax: func Sprintf(format string, a ...interface{}) string Example : Convert an integer variable into String using fmt.Sprintf() function. Go // Go program to illustrate // How to convert integer // variable into String package main import ( "fmt" ) //Main Function func main() { i := 32 s := fmt.Sprintf("%d", i) fmt.Printf("Type : %T \nValue : %v\n", s, s) } Output: Type : string Value : 32 Comment More infoAdvertise with us Next Article Different Ways to Convert an Integer Variable to String in Golang S SHUBHAMSINGH10 Follow Improve Article Tags : Go Language Similar Reads Different Ways to Convert the Boolean Type in String in Golang 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 : C 2 min read How to fetch an Integer variable as String in GoLang? To fetch an Integer variable as String, Go provides strconv package which has methods that return a string representation of int variable. There is nothing like an integer variable is converted to a string variable, rather, you have to store integer value as a string in a string variable. Following 2 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 How to Convert string to integer type in Golang? Strings in Golang is a sequence of variable-width characters where each and every character is represented by one or more bytes using UTF-8 Encoding. In Go language, both signed and unsigned integers are available in four different sizes. In order to convert string to integer type in Golang, you can 2 min read Converting a string variable into Boolean, Integer or Float type in Golang Various types of string conversions are needed while performing tasks in Golang. Package strconv is imported to perform conversions to and from string. String to Boolean Conversion ParseBool is used to convert string to boolean value. It accepts 1, t, T, TRUE, true, True as true and 0, f, F, FALSE, 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 Variable in Golang Variable is a placeholder of the information which can be changed at runtime. And variables allow to Retrieve and Manipulate the stored information. There are 3 ways to find the type of variables in Golang as follows: Using reflect.TypeOf Function Using reflect.ValueOf.Kind() Function Using %T with 2 min read How to Convert string to float type in Golang? ParseFloat function is an in-build function in the strconv library which converts the string type into a floating-point number with the precision specified by bit size. Example: In this example the same string -2.514 is being converted into float data type and then their sum is being printed. Once i 1 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 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 Like