This question already has an answer here:
- Go Error Handling Techniques [closed] 11 answers
I want parse []string
values into particular types (e.g. int, float etc), so I must use different parse functions for different lines. My code:
value, err := strconv.Atoi(line[1])
value1, err := strconv.ParseFloat(line[4], 6)
value2, err := strconv.ParseFloat(line[5], 6)
value3, err := strconv.Atoi(line[2])
I must be sure that every value was parsed so for every value I must have err != nil
. Is there any approach to make it with one common error without
if err != nil {
return
}
after each line?
</div>