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
+48.5k Golang : Upload file from web browser to server
+6.9k Fix sudo yum hang problem with no output or error messages
+11.5k Golang : Handle API query by curl with Gorilla Queries example
+6.8k Golang : Find the longest line of text example
+11.5k Golang : Format numbers to nearest thousands such as kilos millions billions and trillions
+19.6k Golang : Set or Add HTTP Request Headers
+5.4k Golang : Return multiple values from function
+9.5k Golang : Get all countries currencies code in JSON format
+8.1k Golang : Tell color name with OpenCV example
+11.7k Golang : Gorilla web tool kit secure cookie example
+28.8k Golang : Detect (OS) Operating System
+14k Golang : Reverse IP address for reverse DNS lookup example