I want to realize the pause
function like windows shell command pause
. For example,
$ go run script.go
Any key to continue... //Then any key to continue
On windows, we can use the system command by golang function exec.Command()
. But how about on Linux? I want to use the command read -n1 -p "Any key to continue"
as a compromised one, but it doesn't work in the function exec.Command("read", "-n", "1")
. I tested a lot but failed to know why.
Besides, do anyone know how to achieve the pause function just by golang language itself without using the external command?