讨论数量:
流操作,只不过前者基于系统标准输入流,后者是改用文件流。若是要命令行交互,使用 cobra
库更为合适。
// Scan scans text read from standard input, storing successive
// space-separated values into successive arguments. Newlines count
// as space. It returns the number of items successfully scanned.
// If that is less than the number of arguments, err will report why.
func Scan(a ...any) (n int, err error) {
return Fscan(os.Stdin, a...)
}
推荐文章: