Logo

Programming-Idioms

History of Idiom 22 > diff from v15 to v16

Edit summary for version 16 by :

Version 15

2015-08-21, 23:10:19

Version 16

2015-08-21, 23:10:54

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Idiom #22 Convert string to integer

Extract integer value i from its string representation s (in radix 10)

Imports
import "strconv"
Imports
import "strconv"
Code
i, err  := strconv.ParseInt(s, 10, 0)
Code
i, err  := strconv.ParseInt(s, 10, 0)
Comments bubble
Radix 10. Third argument 0 means "fit in implementation-specific int". But result type is always int64.
Don't ignore the potential error err !
Comments bubble
Radix 10. Third argument 0 means "fit in implementation-specific int". But result type is always int64.
Don't ignore the potential error err !
Doc URL
http://golang.org/pkg/strconv/#ParseInt
Origin
http://golang.org/pkg/strconv/