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
+6.7k Golang : When to use make or new?
+9.7k Golang : Load ASN1 encoded DSA public key PEM file example
+11.4k Golang : Delay or limit HTTP requests example
+8.6k Android Studio : Import third-party library or package into Gradle Scripts
+20.2k Golang : Determine if directory is empty with os.File.Readdir() function
+5.6k PHP : Fix Call to undefined function curl_init() error
+9.4k Golang : Apply Histogram Equalization to color images
+20.7k Android Studio : AlertDialog and EditText to get user string input example
+4.8k Which content-type(MIME type) to use for JSON data
+13.5k Golang : Read XML elements data with xml.CharData example
+5.2k Golang : Customize scanner.Scanner to treat dash as part of identifier
+20.7k Golang : Saving private and public key to files