diff --git a/os/gcmd/gcmd_scan.go b/os/gcmd/gcmd_scan.go index 12fb98f86..c2c528a68 100644 --- a/os/gcmd/gcmd_scan.go +++ b/os/gcmd/gcmd_scan.go @@ -7,13 +7,21 @@ package gcmd -import "fmt" +import ( + "bufio" + "fmt" + "os" + + "github.com/gogf/gf/text/gstr" +) // Scan prints to stdout, reads and returns user input, which stops by '\n'. func Scan(info ...interface{}) string { var s string fmt.Print(info...) - fmt.Scanln(&s) + reader := bufio.NewReader(os.Stdin) + s, _ = reader.ReadString('\n') + s = gstr.Trim(s) return s }