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
+17.6k How to enable MariaDB/MySQL logs ?
+24.4k Golang : How to validate URL the right way
+21.7k Golang : Upload big file (larger than 100MB) to AWS S3 with multipart upload
+4.6k Mac OSX : Get disk partitions' size, type and name
+12.2k Golang : How to display image file or expose CSS, JS files from localhost?
+12.4k Golang : flag provided but not defined error
+11k Golang : Web routing/multiplex example
+15.1k Golang : How to add color to string?
+29.7k Golang : Get and Set User-Agent examples
+22.6k Golang : Strings to lowercase and uppercase example
+13.5k Golang : Set image canvas or background to transparent
+11k Google Maps URL parameters configuration