在2020年11月14日星期六 UTC+8 上午3:09:24<Gregg Townsend> 写道:
> If I understand what you're trying to do, I'd approach it this way, using > a generously buffered channel and discarding the extras at the consumer, as > shown below, instead of at the producer: > > result <- c // wait for result to appear > for len(c) > 0 { > // there is a newer result available > result <- c > } > // process latest available result > > In normal case I don't want to discarding. Even consumer find the channel > is full, it should not to discard. > > >> -- 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/dfb924b6-6eb0-406d-9c51-b396d1181078n%40googlegroups.com.