Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Scan int

package main

import "fmt"

func main() {
	var number int
	fmt.Print("Type in a number: ")
	fmt.Scan(&number)
	fmt.Println(number)
}
  • Accepts an integer
  • Accepts a single character (and gives 0) but the second character is left on the SDTIN buffer
  • TODO: try also with int8 type