Skip to main content Link Search Menu Expand Document (external link)

Reading from STDIN

The fmt package offers methods to scan input from the terminal line:

fmt.Printf("Please give me your name: ")
var name string
fmt.Scanln(&name)
fmt.Println("Your name is", name)

Command Line Arguments

os.Args

By default, go allows to read arguments passed to the binary, in the form of the os.Args string slice

1