Interfaces in Go - Discovering Behavior
HTML-код
- Опубликовано: 8 июл 2024
- Learn Go interfaces by refactoring code to discover interfaces based on the behavior of concrete types. Enjoy!
00:00 Introduction
00:27 Quotes for Interfaces
01:25 Notifying with a Discord Client
03:02 Adding an Email Client
05:02 Discovering the Notifier Interface
08:48 Extending the Notifier Interface
13:00 Accept Interfaces, Return Structs
15:17 Implementing a Mock Notifier for Testing
19:53 Recap of Interfaces
22:10 Final Thoughts
Find the code at github.com/sudomateo/sudomateo.
Personal Website: matthewsanabria.dev
GitHub: github.com/sudomateo
LinkedIn: / sudomateo
Twitter: / sudomateo
Mastodon: mastodon.online/@sudomateo
RUclips: / @sudomateo Наука
Please excuse the nasally voice. I recorded this just as I was getting sick so I was a bit stuffy.
👏👏👏
MOM! Wake up! Matthew uploaded a new video!
This is the way!
Loving the go content, so clear and easy to grasp. I would pay for your courses 😆
Thank you for the kind words! I'm not against creating course content, I would just need to dedicate time to creating the content and make sure it's financially accessible to everyone. I have some strong opinions on some of the course content out there that takes advantage of aspiring engineers.
Fair enough :I)
Also a future video suggestion: concurrency stuff (channel and mutex)
@@0lange I got you! Concurrency stuff is next on the list. I ranked some suggestions based on frequency and concurrency was top 3. I'll be recording that when I'm back from GopherCon.
Don't forget to hit that bell!
Like. Subscribe. Hit the bell. Grow the beard. All the good things!
I like this content. Just one thing I know this is a jus a simple example but you are not testing the SendNotification function at all here. I see that you want show how you can take benefit of interfaces to create mocks that can help during unit tests, but this is a little bit misleading on how write a good unit test. By the way I appreciate your efforts and I am waiting for other content related to Golang. B.R.
Thank you! More content will be coming soon. I wasn't going to include any testing in this video at first but the I was like ah heck why not? I really wanted to show how one can implement interfaces to be used in tests rather than writing a perfect unit test. I probably should have asserted on the message to test the behavior specific to SendNotification. In the current form it's really just testing that the notifier(s) get called.