Debian Codegraph @

util/prompt.go

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 package util
2
3 import (
4 "bufio"
5 "fmt"
6 "os"
7
•8 "golang.org/x/term"
9 )
10
11 // Prompt prompts user for input with default value.
12 func Prompt(prompt string) string {
13 reader := bufio.NewReader(os.Stdin)
14 fmt.Print(prompt)
15 text, _ := reader.ReadString('\n')
16 return text
17 }
18
19 // PromptPassword prompts user for password input.
20 func PromptPassword(prompt string) string {
21 fmt.Printf(prompt)
•22 b, err := term.ReadPassword(int(os.Stdin.Fd()))
23 if err != nil {
24 fmt.Println(err.Error())
25 return ""
26 }
27 return string(b)
28 }