I'm working on a piece of code that returns uint data type. I need to convert uint datatype into string for further processing.
I've already tried strconv package and none of the functions accept uint. Golang Documentation: https://golang.org/ref/spec#Numeric_types states that uint are platform dependent. Is that the reason we don't have any standard functions for conversion?
type Example{
Id uint //value 3
name string
}
Need to extract Id into a string.
Expected: "3" Actual: N/A
Use strconv.FormatUint()
:
package main
import (
"fmt"
"strconv"
)
func main() {
var n uint = 123
var s string = strconv.FormatUint(uint64(n), 10)
fmt.Printf("s=%s
", s)
}