Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "os"
- "fmt"
- )
- // A simple program that verifies the user by username and password.
- var loginstatus bool
- var username, password string
- func login(username, password string) bool {
- if username == "user123" && password == "pass123" {
- return true
- } else {
- return false
- }
- }
- func main() {
- fmt.Print("Username: ")
- user := bufio.NewScanner(os.Stdin)
- fmt.Print("Password: ")
- pass := bufio.NewScanner(os.Stdin)
- for user.Scan() && pass.Scan() {
- if login(user.Text(), pass.Text()) {
- fmt.Println("Signed in.")
- os.Exit(3)
- } else {
- fmt.Println("Incorrect username or password, please try again:")
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement