一、界面不显示输入内容 package main import ( "golang.org/x/crypto/ssh/terminal" "os" "fmt" ) func main(){ tmp,_ := terminal.ReadPassword(int(os.Stdin.Fd())) word := string(tmp) fmt.Println("---",word) } 二、界面显示输入内容
一、界面不显示输入内容
package mainimport (
"golang.org/x/crypto/ssh/terminal"
"os"
"fmt"
)
func main(){
tmp,_ := terminal.ReadPassword(int(os.Stdin.Fd()))
word := string(tmp)
fmt.Println("---",word)
}
二、界面显示输入内容
package mainimport (
"fmt"
"bufio"
"os"
)
func main(){
scanner := bufio.NewScanner(os.Stdin)
fmt.Println("Please input text")
scanner.Scan()
text := scanner.Text()
fmt.Println("====",text)
}