Golang : Convert uint value to string type
Problem :
You have an uint value and you want to convert(cast) the value into string.
Solution :
Use strconv.FormatUint()
function to convert the uint64 value to string.
For example :
package main
import (
"fmt"
"strconv"
)
func main() {
var uval uint64 = 1 * (1 << 20)
str := strconv.FormatUint(uval, 10)
fmt.Println(str) // uint64 in string format
}
See also : Golang : Convert(cast) int to int64
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+10.7k Golang : Simple client-server HMAC authentication without SSL example
+22.3k Golang : Use regular expression to validate domain name
+5.5k Golang : Spell checking with ispell example
+8.8k Golang : Compare files modify date example
+5k Golang : Experimenting with the Rejang script
+13k Golang : How to get URL port?
+17.1k Golang : Send email with attachment
+31k Golang : Smarter Error Handling with strings.Contains()
+72.1k Golang : How to return HTTP status code?
+6.8k Golang : Get all countries phone codes
+31.7k Golang : Converting a negative number to positive number
+18.2k Golang : Archive directory with tar and gzip