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
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.