Home / Companies / Cloudflare / Blog / Post Details
Content Deep Dive

Go interfaces make test stubbing easy

Blog post from Cloudflare

Post Details
Company
Date Published
Author
John Graham-Cumming
Word Count
666
Company Posts That Month
7
Language
English
Hacker News Points
78
Post removed?
No
Summary

In a piece of software designed for image compression, John Graham-Cumming discovered an effective use of interfaces in Go programming language. The Worker package runs jobs in goroutines and expects them to have a "Do" method. By defining a Job interface with the required methods, he was able to create a DummyJob that could be used for testing without needing to configure complex job types. This approach greatly simplified the unit test suite and demonstrated the power of interfaces in Go programming.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.