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
+32.4k Golang : Math pow(the power of x^y) example
+11.2k Golang : Calculate Relative Strength Index(RSI) example
+5.4k Golang : Intercept, inject and replay HTTP traffics from web server
+4.4k Golang : Valued expressions and functions example
+30k Golang : Get time.Duration in year, month, week or day
+7k Golang : Gargish-English language translator
+7.1k Nginx : How to block user agent ?
+6.4k Golang : How to search a list of records or data structures
+10.2k Golang : Use regular expression to get all upper case or lower case characters example
+10.1k Golang : How to tokenize source code with text/scanner package?
+5.6k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+12k Golang : Clean formatting/indenting or pretty print JSON result