Thank you, That is what I did. It works very well. Thank you again On Fri, Apr 15, 2022 at 8:48 PM Kurtis Rader <kra...@skepticism.us> wrote:
> On Fri, Apr 15, 2022 at 6:35 AM Daniel Jankins <djank...@gmail.com> wrote: > >> I have a newbie question. I want to loop until a char is available >> (keypress). >> Could someone point me to an example. >> > > I can't point you to an example because that wouldn't be idiomatic Go; > thus such examples are (I hope) hard to find. In Go you shouldn't busy wait > using a function like "kbhit > <https://www.geeksforgeeks.org/kbhit-c-language/>" . You should create a > channel for communicating the keys that are seen, create a goroutine that > reads from os.Stdin and injects keys into that channel, then use an event > loop in a different goroutine that uses "select > <https://go.dev/ref/spec#Select_statements>" to read key events from that > channel. > > -- > Kurtis Rader > Caretaker of the exceptional canines Junior and Hank > -- DanJ -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CACHdq71dfr7EP6PGgEMJ88GLgqqYS3rziT9ya35iZCz6P2CVrA%40mail.gmail.com.