On Fri, 1 Nov 2019, 21:07 burak sarac, <burak...@gmail.com> wrote: > I have a go routine running something like 'hash.sum(data)' using import > "hash" that I want to terminate immediately in case of user wants to > kill, I can not send channel to notify. >
I have not tried this, but you can use a combination of defer, panic and recover to unroll the process. The recover function is inside calculate, and the for-loop is running in goroutine before calculate. defer func() { recover() } go loop() calculate() Inside the loop() you will call panic("terminate"). -- Shulhan > -- 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/CAMh9%2BYA%3DYW9gp6gtduRMyh_Zu567CJ97r8PcR-Wzp9HEz2%2BxHg%40mail.gmail.com.