Skip to Content
Hands-On Software Engineering with Golang
book

Hands-On Software Engineering with Golang

by Achilleas Anagnostopoulos
January 2020
Intermediate to advanced
640 pages
16h 56m
English
Packt Publishing
Content preview from Hands-On Software Engineering with Golang

Testing timeouts is easy when you have all the time in the world!

I am pretty sure that, at some point, you have written some code that relies on the time-keeping functions provided by the standard library's time package. Perhaps it's some code that periodically polls a remote endpoint a great case for using time.NewTicker – or maybe you are using time.After to implement a timeout mechanism inside a go-routine that waits for an event to occur. In a slightly different scenario, using time.NewTimer to provide your server code with ample time to drain all its connections before shutting down would also be a stellar idea.

However, testing code that uses any of these patterns is not a trivial thing. For example, let's say that you are trying ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Software Architecture with Golang

Hands-On Software Architecture with Golang

Jyotiswarup Raiturkar

Publisher Resources

ISBN: 9781838554491Supplemental Content