Golang strconv.FormatUint() function “converts unsigned integer values (e.g., uint, uint16, uint32, uint64) to strings”. The FormatUint() function takes two arguments: the unsigned integer value (as uint64) and the base (radix) of the number system to use for the string representation.
Syntax
func FormatUint(i uint64, base int) string
Parameters
- “i” is the unsigned integer value of type uint64 that you want to convert to a string representation.
- “base” is an int representing the base (radix) of the number system to use for the string representation (e.g., 2 for binary, 10 for decimal, 16 for hexadecimal).
Return value
The FormatUint() function returns a string representing the given unsigned integer value in the specified base.
Example
package main
import (
"fmt"
"strconv"
)
func main() {
var myUint uint = 123
// Convert uint to string using strconv.FormatUint() with base 10 (decimal)
myString := strconv.FormatUint(uint64(myUint), 10)
fmt.Println("Converted uint to string:", myString)
}
Output
Converted uint to string: 123
In this code, we converted a uint value to a decimal string representation by casting the uint value to uint64 and then passing it along with the base 10 to the strconv.FormatUint() function. The resulting string is printed to the console.

Krunal Lathiya is a Software Engineer with over eight years of experience. He has developed a strong foundation in computer science principles and a passion for problem-solving. In addition, Krunal has excellent knowledge of Distributed and cloud computing and is an expert in Go Language.