Using `context` is the recommended mechanism to pass timeouts and other information to functions, so it's probably already the "best" way, at least from the design point of view.
I recommend benchmarking it before searching for other solutions: if it turns out to cause excessive slowdown, there are some tricks you can use. A quite hackish solution that just came to my mind is this: in the GoAWK interpreter you will surely have some "interpreter context" struct, probably full of often-used pointers. To set a timeout, you could spawn a goroutine that, after a specified time, sets one or more of these pointers to nil. The interpreter would then panic due to a nil pointer dereference, and you'd need to recover() from that panic in the top-most interpreter function/method. And of course you also need to save those pointers somewhere, in order to restore their values at the beginning of the next interpreter call. As I said, quite hackish. Regards, Cosmos72 -- 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/4c062256-8aa3-4036-9788-3965e342c31d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.