tags:

views:

79

answers:

1

How do I use the fmt.Scanf function in golang to get an integer input from the standard input ?

If this can't be done using fmt.Scanf, what's the best way to read a single integer ?

Thanks :)

+2  A: 

http://golang.org/pkg/fmt/#Scanf

All the included libraries in Go are well documented.

That being said, I believe

func main() {
    var i int
    fmt.Scanf("%d", &i)
}

does the trick

cthom06
Thank you :) it does work, I was being an idiot, didn't use the quotes.
yasith
@yasith happens to us all sometimes
cthom06