go - Golang : convert uint8 to string -
http://play.golang.org/p/bozkhc8_ua
i want convert uint8 string can't figure out how.
package main import "fmt" import "strconv" func main() { str := "hello" fmt.println(str[1]) // 101 fmt.println(strconv.itoa(str[1])) }
this gives me prog.go:11: cannot use str[1] (type uint8) type int in function argument [process exited non-zero status]
any idea?
simply convert it :
fmt.println(strconv.itoa(int(str[1])))
Comments
Post a Comment