How to timeout tests in Go

3 minute read Published: 2019-07-22

Today I want to share a nice trick I found while inspecting the test file for the bufio in the standard library.

It is about how we can make a test case fail if it take more than X seconds, where X is an arbitrary value we chose.