This just in! When is a constructor that returns an interface appropriate? π€
Update: 2024-05-17
Description
- Upcoming conferences
- π―π΅ June 8: Go Conference 2024 @ Tokyo, Japan
- π©πͺ June 17-20: GopherCon EU @ Berlin, Germany
- π³π± June 19-21: DevOps Days @ Amsterdam, Netherlands
- π·πΊ June 24-25: Golang Conf 2024 @ St. Petersburg, Russia
- Proposals
- π Accepted: go telemetry subcommand
- Previous discussion on Episode 62
- β Declined: Notify of new major dependency versions
- Previous discussion on Episode 62
- π New: Make math/rand.Seed a no-op
- π Accepted: go telemetry subcommand
- The unique package has been implemented
- β Previous discussion on Episode 33
- Around the community
- π€ Reddit: Is it idiomatic to create a constructor that returns an interface?
- GitHub CLI 2.49.1 includes contribution from Shay
β Support this podcast on Patreon β
In Channel




"Depend on abstraction, pass realization" is letter "D" in SOLID principles - dependency inversion principle. You should know what it means, don't you? )
There is no point in creating the interface in tests since all the places you are going to pass data will accept your struct.