Golang fmt.Scanln() function example
package fmt
Scanln is similar to Scan, but stops scanning at a newline and after the final item there must be a newline or EOF.
Golang fmt.Scanln() function usage example
package main
import (
"fmt"
)
func main() {
var input string
fmt.Println("Who will inherit this planet after we are gone ? ")
fmt.Scanln(&input) //<--- here
fmt.Println("Your answer : ", input)
}
Sample output :
Who will inherit this planet after we are gone ?
Alien
Your answer : Alien
Reference :
Advertisement
Something interesting
Tutorials
+33.9k Golang : Call a function after some delay(time.Sleep and Tick)
+11.3k Golang : How to use if, eq and print properly in html template
+39.6k Golang : Remove dashes(or any character) from string
+30.8k Golang : Download file example
+17.7k Golang : [json: cannot unmarshal object into Go value of type]
+36k Golang : Get file last modified date and time
+5.9k Facebook : How to force facebook to scrape latest URL link data?
+5.7k List of Golang XML tutorials
+6.9k Golang : Fibonacci number generator examples
+9k Golang : Populate or initialize struct with values example
+11.6k Golang : Concurrency and goroutine example