Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is this Golang code to convert a string to an integer failing?

Tags:

go

This should have been simple:

strconv.Atoi("1250000.0000")

This results in an error:

0 strconv.ParseInt: parsing "1250000.0000": invalid syntax

Any clues?


1 Answers

Atoi works only for strings that can be parsed as integers.

What you need is parseFloat

like image 164
Denys Séguret Avatar answered Sep 19 '25 15:09

Denys Séguret