Hi there! This is a question I recently posted to Reddit. I wanted to post it here as well in order to get even more insight :) .
I am a new Gophe...
For further actions, you may consider blocking this person and/or reporting abuse
Try this instead:
catfactsor whatever else. In this define the things you need to build your app.Now when you want to implement
Senderwith say Twilio, create a package for that.Now if you ever want to create a new sender, you just create a new package based on the impl. I just needs to implement
catfacts.Sender.Back to
catfacts, you can createSendFactToSubscribersusing your interfaces:Rinse and repeat for any other impls you need - eg
package sqlitemight have an sqlite impl of theSubscriberStore.This may be a good point to continue this thinking: medium.com/@benbjohnson/standard-p...
I also started writing about this and hope to have more examples in the future, but I'll admit this series has taken the back seat to other work lately: calhoun.io/structuring-web-applica...
There isn't a single "best way" to write apps in Go, but this approach tends to work better for me.
Awesome! Thanks for such an informative response :) . I think when learning a new language it's good to try out different approaches to writing apps since like you said there is no one best way, this was a fantastic look at a way to organize code.
You should definitely experiment a bit. Almost all of the pros/cons of each approach need to be learned firsthand to really sink it, and every approach doesn't fit every problem.
It can be a bit challenging with smaller apps because some of the problems (cyclical deps, etc) won't show up until an app gets to a certain size, but still worth experimenting.