On Monday 14 October 2024 at 22:57:07 UTC+1 Peter Bočan wrote: What is the recommended way of reading whatever is on the buffer and return back without blocking?
If you just want to poll, and get whatever data is available: set a deadline of "just after now", and read. https://go.dev/play/p/bFDh7gqpeYc [Note: doesn't work properly in the playground; I don't know why] If you want to do other concurrent work and/or select between multiple sources: use a goroutine to read and pass the data down a channel, and closes the channel when done. -- 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/bd225fb3-4697-4ad8-bff2-6e5322953fa3n%40googlegroups.com.