http://play.golang.org/p/7kR2uZlV5-
This is my playground link. I have an array of numbers but in string. I tried to convert them to float number but it does not give me anything. What is wrong with it?
var numbers []float64
for _, elem := range str_numbers {
i, err := strconv.ParseFloat(elem, 64)
if err != nil {
numbers = append(numbers, i)
}
}
fmt.Println(numbers)
// this gives me nothing []
Change
if err != nil {
to
if err == nil {
(You may be doing this already, but unit testing is a great way to catch bugs like this.)