|
@@ -17,6 +17,8 @@
|
|
|
package terminal
|
|
package terminal
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
|
+ "os"
|
|
|
|
|
+
|
|
|
"golang.org/x/sys/windows"
|
|
"golang.org/x/sys/windows"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -71,13 +73,6 @@ func GetSize(fd int) (width, height int, err error) {
|
|
|
return int(info.Size.X), int(info.Size.Y), nil
|
|
return int(info.Size.X), int(info.Size.Y), nil
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// passwordReader is an io.Reader that reads from a specific Windows HANDLE.
|
|
|
|
|
-type passwordReader int
|
|
|
|
|
-
|
|
|
|
|
-func (r passwordReader) Read(buf []byte) (int, error) {
|
|
|
|
|
- return windows.Read(windows.Handle(r), buf)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// ReadPassword reads a line of input from a terminal without local echo. This
|
|
// ReadPassword reads a line of input from a terminal without local echo. This
|
|
|
// is commonly used for inputting passwords and other sensitive data. The slice
|
|
// is commonly used for inputting passwords and other sensitive data. The slice
|
|
|
// returned does not include the \n.
|
|
// returned does not include the \n.
|
|
@@ -98,5 +93,5 @@ func ReadPassword(fd int) ([]byte, error) {
|
|
|
windows.SetConsoleMode(windows.Handle(fd), old)
|
|
windows.SetConsoleMode(windows.Handle(fd), old)
|
|
|
}()
|
|
}()
|
|
|
|
|
|
|
|
- return readPasswordLine(passwordReader(fd))
|
|
|
|
|
|
|
+ return readPasswordLine(os.NewFile(uintptr(fd), "stdin"))
|
|
|
}
|
|
}
|