February 2018
Intermediate to advanced
340 pages
9h 43m
English
The timeout for the long-running operation in the previous code is implemented with the use of the time.After function, which provides the channel delivering the tick after the given period.
The operation itself is wrapped to select a statement which chooses between the time.After channel and the default option, which executes the operation.
Note that you need to allow the code to read from the time.After channel periodically to find out whether the timeout is exceeded or not. Otherwise, if the default code branch blocks the execution entirely, there is no way how to find out if the timeout has already elapsed.
Read now
Unlock full access