Read a character from standard input in Go (without pressing Enter)

前端 未结 6 1676
甜味超标
甜味超标 2020-12-08 20:29

I want to my app shows:

press any key to exit ...

And when I pressed any key, it exits.

How can I achieve this?

6条回答
  •  时光说笑
    2020-12-08 20:41

    Try this - http://play.golang.org/p/kg-QirlucY.

    Just read from the os.Stdin at the end of the func main

提交回复
热议问题