go - Converting []uint8 to float64 -


what best way handle http resp.body formatted []uint8 , not json? convert bytes float64.

this returned value response:

value : %!f([]uint8=[48 46 48 48 49 50 53 53 50 49]) 

try using parsefloat strconv package (play):

b := []uint8{48, 46, 48, 48, 49, 50, 53, 53, 50, 49}  f, err := strconv.parsefloat(string(b), 64)  if err != nil {      // handle parse error }  fmt.printf("%f\n", f) // 0.001255 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -