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