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

Using Go interfaces effectively

"Accept interfaces, return structs."
- Jack Lindamood

The key point behind organizing code into packages is to make it reusable and available to external consumers in a frictionless way by providing a clean, well-documented API surface that consumers can build on. When authoring functions or methods that accept concrete types as arguments, we place an artificial constraint on the usefulness of our implementation: it only works with instances of a particular type.

While this may not always be an issue, in some cases, requiring a concrete type instance can potentially make testing non-trivial and slow, especially if the construction of such an instance is a costly operation. The following excerpt is part of a ...

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