From 7c8f976d2a4530b7af8110129ee55159a3c741ed Mon Sep 17 00:00:00 2001 From: "Ling Samuel (WSL)" Date: Fri, 10 Nov 2023 09:17:56 +0800 Subject: [PATCH] chore: stdin support windows Signed-off-by: Ling Samuel (WSL) --- cmd/configure.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/configure.go b/cmd/configure.go index 4b192ca9..f39e600f 100644 --- a/cmd/configure.go +++ b/cmd/configure.go @@ -9,16 +9,14 @@ import ( "crypto/x509" "errors" "fmt" - "net/url" - "os" - "path/filepath" - "strings" - "syscall" - "github.com/fatih/color" "github.com/spf13/cobra" "github.com/spf13/viper" "golang.org/x/term" + "net/url" + "os" + "path/filepath" + "strings" ) // newConfigureCmd represents the configure command @@ -177,8 +175,8 @@ func saveConfiguration(cmd *cobra.Command) error { if rootConfig.Token == "" || overwrite { fmt.Println("Please enter the APISIX token: ") - if term.IsTerminal(syscall.Stdin) { - token, err := term.ReadPassword(syscall.Stdin) + if term.IsTerminal(int(os.Stdin.Fd())) { + token, err := term.ReadPassword(int(os.Stdin.Fd())) if err != nil { return err }