Logo

Programming-Idioms

History of Idiom 22 > diff from v14 to v15

Edit summary for version 15 by :

Version 14

2015-08-21, 06:25:00

Version 15

2015-08-21, 23:10:19

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.Atoi(s) 
Code
i, err  := strconv.Atoi(s) 
Comments bubble
Atoi(s) is shorthand for ParseInt(s, 10, 0). It yields type int.
Comments bubble
Atoi(s) is shorthand for ParseInt(s, 10, 0). It yields type int.
Doc URL
http://golang.org/pkg/strconv/
Origin
http://golang.org/pkg/strconv/
Demo URL
http://play.golang.org/p/VXjGHZbj6J
Demo URL
http://play.golang.org/p/VXjGHZbj6J