consoleutil

package
v1.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearScreen

func ClearScreen()

ClearScreen 清理控制台屏幕

func ReadInput

func ReadInput(scanner *bufio.Scanner) (input string, ok bool)

ReadInput 等待用户输入一行,返回去除 BOM 及首尾空白后的内容。 返回值 ok 为 false 表示输入流已结束(如 Ctrl+Z)或读取出错,调用方应退出。

func ReadPassword

func ReadPassword(scanner *bufio.Scanner) (password string, ok bool)

ReadPassword 以不回显方式录入密码(输入时不显示任何字符)。 终端下使用 x/term 关闭回显;非终端(如管道/重定向,常见于自动化测试)回退到 readInput。 返回 (密码, ok),ok 为 false 表示读取失败,调用方应退出。

func WaitAnyKey

func WaitAnyKey(prompt string)

WaitAnyKey 等待用户按下任意键后继续(读单个按键即可返回,无需按回车), 常用于程序结束前提示"按任意键退出"等场景。 终端下先输出提示,再通过 x/term 原始模式读取一个按键; 非终端(如管道/重定向输入)退化为读取一行,避免程序被卡死。

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL