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.4k Golang : Convert decimal number(integer) to IPv4 address
+11.1k Golang : Extract part of string with regular expression
+9.9k Golang : Proper way to test CIDR membership of an IP 4 or 6 address example
+14.9k Golang : Get file permission
+35.5k Upload multiple files with Go
+7.2k Swift : Convert (cast) Character to Integer?
+5k Golang : Get missing location after unmarshal binary and gob decode time.
+22.6k Golang : Upload to S3 with official aws-sdk-go package
+7.1k Golang : Emulate NumPy way of creating matrix example
+7.2k Golang : Metaprogramming example of wrapping a function
+13.8k Golang : Force download file example
+4.4k Golang : If else example and common mistake