Logo

Programming-Idioms

History of Idiom 120 > diff from v29 to v30

Edit summary for version 30 by programming-idioms.org:
[Go] Better not ignore the error

Version 29

2018-06-24, 08:08:11

Version 30

2018-06-24, 08:09:47

Idiom #120 Read integer from stdin

Read an integer value from the standard input into variable n.

Idiom #120 Read integer from stdin

Read an integer value from the standard input into variable n.

Imports
import "fmt"
Imports
import "fmt"
Code
fmt.Scan(&n)
Code
_, err := fmt.Scan(&n)
Comments bubble
Warning: if the input has a leading 0, it will be interpreted as octal!
Comments bubble
Warning: if the input has a leading 0, it will be interpreted as octal!
Doc URL
https://golang.org/pkg/fmt/#Scan
Doc URL
https://golang.org/pkg/fmt/#Scan
Demo URL
https://play.golang.org/p/nhMp1C03vBN
Demo URL
https://play.golang.org/p/1D32GAtQksq