mirror of
https://github.com/mudabbir-ahmad/LearningGo.git
synced 2026-10-07 17:50:20 +00:00
40 lines
778 B
Go
40 lines
778 B
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
func check(e error) {
|
|
if e != nil {
|
|
panic(e)
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
reader := bufio.NewReader(os.Stdin)
|
|
|
|
// 1. Ask for Username
|
|
fmt.Print("Username: ")
|
|
usernameInput, err := reader.ReadString('\n')
|
|
|
|
check(err)
|
|
username := strings.TrimSpace(usernameInput)
|
|
|
|
// 2. Ask for Password (with asterisk masking)
|
|
fmt.Print("Password: ")
|
|
passwordIn, _ := reader.ReadString('\n')
|
|
password := string(passwordIn)
|
|
|
|
// 3. Output results
|
|
fmt.Println("\n--- Result ---")
|
|
fmt.Println("Username:", username)
|
|
fmt.Println("Password:", password)
|
|
|
|
fmt.Print("The delim should cause you to end the line whenever you press back slash, then hit enter:p \n")
|
|
test, _ := reader.ReadString('\\')
|
|
fmt.Println("You entered:", test)
|
|
}
|