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()

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 

Reply via email to