Reputation: 436
I've infinite loop in my app and I need add one more functionality. Something like, "Press any key to exit...".
It's my code. Who knows the golden idea?
func main() {
for {
doAll()
}
}
Upvotes: 2
Views: 2316
Reputation: 59002
One option would be to start doAll
in a goroutine and call fmt.Scanf:
func main() {
go func() {
for {
doAll()
}
}()
fmt.Println("Press any key to exit")
var input string
fmt.Scanf(input, "%s")
}
Upvotes: 7