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
+52.9k Golang : How to get struct field and value by name
+11.9k Golang : Find age or leap age from date of birth example
+19.1k Golang : How to make function callback or pass value from function as parameter?
+18.7k Golang : Logging with logrus
+13.9k Golang : Get user input until a command or receive a word to stop
+6.6k Golang : How to search a list of records or data structures
+17.6k Golang : Linked list example
+9.3k Golang : Simple histogram example
+11.7k Use systeminfo to find out installed Windows Hotfix(s) or updates
+51.6k Golang : Check if item is in slice/array
+23.3k Golang : simulate tail -f or read last line from log file example
+19k Golang : Delete duplicate items from a slice/array