mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
fix default prompts
This commit is contained in:
parent
2da21ec528
commit
e96e0e0999
1 changed files with 12 additions and 3 deletions
|
|
@ -4,7 +4,9 @@ import (
|
|||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Prompt asks the user for a value
|
||||
|
|
@ -16,9 +18,16 @@ func Prompt(question string, defaultValue ...string) string {
|
|||
question = fmt.Sprintf("%s (%s)", question, answer)
|
||||
}
|
||||
fmt.Printf(question + ": ")
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
if scanner.Scan() {
|
||||
answer = scanner.Text()
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
input, _ := reader.ReadString('\n')
|
||||
EOL := "\n"
|
||||
if runtime.GOOS == "windows" {
|
||||
EOL = "\r\n"
|
||||
}
|
||||
input = strings.Replace(input, EOL, "", -1)
|
||||
|
||||
if input != "" {
|
||||
answer = input
|
||||
}
|
||||
|
||||
return answer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue