Improve string reading logic for no input

This commit is contained in:
comp500 2019-06-16 21:06:23 +01:00
parent f0516b8600
commit 2ab625c650
No known key found for this signature in database
GPG Key ID: 214C822FFEC586B5

View File

@ -5,6 +5,7 @@ import (
"log" "log"
"os" "os"
"strings" "strings"
"bufio"
"github.com/comp500/packwiz/core" "github.com/comp500/packwiz/core"
"github.com/urfave/cli" "github.com/urfave/cli"
@ -208,8 +209,7 @@ func cmdUpdate(flags core.Flags, mod string) error {
} }
fmt.Print("Do you want to update? [Y/n]: ") fmt.Print("Do you want to update? [Y/n]: ")
var answer string answer, err := bufio.NewReader(os.Stdin).ReadString('\n')
_, err := fmt.Scanln(&answer)
if err != nil { if err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }