Timing Out a Goroutine
Let’s learn about timing out a goroutine inside and outside of the main() function.
There are times that goroutines take more time than expected to finish—in such situations, we want to time out the goroutines so that we can unblock the program. This lesson presents two such techniques.
Timing out a goroutine – inside main()
Let’s discuss a simple technique for timing out a goroutine.
Coding example
The relevant code can be found in the main()
function of timeOut1.go
:
Get hands-on with 1400+ tech skills courses.