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
+8.5k Golang : How to check variable or object type during runtime?
+6.9k Mac/Linux/Windows : Get CPU information from command line
+8.3k Golang : Count leading or ending zeros(any item of interest) example
+5.1k Swift : Convert (cast) Float to Int or Int32 value
+7k Web : How to see your website from different countries?
+5.4k Unix/Linux : How to archive and compress entire directory ?
+5.3k Swift : Convert string array to array example
+8.4k Golang : Generate Datamatrix barcode
+4.8k Golang : A program that contain another program and executes it during run-time
+5.4k Golang : What is StructTag and how to get StructTag's value?
+5.4k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+4.5k Java : Generate multiplication table example