Why does this doesn’t work, or how to get multiple input with fmt.Scanln?
EDIT: If I insert more then one word then I get the Error “Scan: expected newline”, anything I can do about this?
var username string
print("Username: ")
_, err := fmt.Scanln(&username)
if err != nil {
fmt.Println("Error: ", err)
}
var password string
print("Password: ")
_, err := fmt.Scanln(&password)
if err != nil {
fmt.Println("Error: ", err)
}
var status string
print("Status: ")
_, err := fmt.Scanln(&status)
if err != nil {
fmt.Println("Error: ", err)
}
fmt.Println(username, password, status)
You are re-declaring the err variable multiple times in the same scope.
The compiler error should have made that clear. The following will work: