A Practical Example How To Use Interfaces In Golang

  Рет қаралды 25,075

Anthony GG

Anthony GG

Күн бұрын

► Join my Discord community for free education 👉 / discord
► Exclusive Lessons, Mentorship, And Videos 👉 / anthonygg_
► 33% OFF on my Go + HTMX + Templ Course PRESALE 👉bit.ly/3UFruxO
► Enjoy a 60% Black Friday Discount on My Golang Course 👉 fulltimegodev.com
► Learn how I became a self-taught software engineer 👉fulltimegodev....
► Follow me on Twitter 👉 / anthdm
► Follow me on GitHub 👉 github.com/anthdm
Grab yourself a 33% OFF on the PRESALE event of my building production ready applications with GO + HTMX + Templ + Tailwindcss + JQuery course here: bit.ly/3UFruxO
Golang interfaces: • This Will Make Everyon...
Golang package context: • How To Use The Context...
SUBSCRIBE OR NO MARGARITAS
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝

Пікірлер: 39
@anthonygg_
@anthonygg_ 6 ай бұрын
► 33% OFF on my Go + HTMX + Templ Course PRESALE 👉bit.ly/3UFruxO ► Join my Discord community for free education 👉 discord.com/invite/Ac7CWREe58 ► Exclusive Lessons, Mentorship, And Videos 👉 www.patreon.com/anthonygg_ ► 60% OFF on my Golang course 👉 fulltimegodev.com Thanks for watching
@chandler828
@chandler828 6 ай бұрын
So much better than the overused geometry/shapes interface example. Well done.
@croncoder862
@croncoder862 6 ай бұрын
exactly, especially if you come from a Java or C# background, it looks really silly when people talk about all that
@wuiqed
@wuiqed 6 ай бұрын
Like those OOP tutorials we all read when we first started learning programming. Create a Car class. Give it model and color properties. Add drive and honk methods. MyCar.honk(). "Beep, beep!" Ok, now what? How about a practical example? Fuck that, now you surely understand OOP, onto the next half-assed subject.
@croncoder862
@croncoder862 6 ай бұрын
You dropped this video just as I am building my own notifications engine in golang with support for various connectors🤣
@ada0015
@ada0015 5 ай бұрын
I'm new to Golang (
@croncoder862
@croncoder862 4 ай бұрын
@@ada0015 anywhere where you need a bunch of configs. moreover what anthony has shown here is an open ended design. meaning you wont have breaking api changes
@TannerBarcelos
@TannerBarcelos 6 ай бұрын
The worst thing about interface tutorials, and the “polymorphism” examples in C++ classes in school, are the usual shape example. While it gets you going, it’s not practical at all. This tutorial made the whole paradigm so much easier to understand.
@ThePandaGuitar
@ThePandaGuitar 6 ай бұрын
i love these high level golang videos that focus on patterns
@zevo92
@zevo92 6 ай бұрын
Great exemplification of a good practice by using simple yet powerful patterns. I think a video showing "the over-engineering" use of interfaces would also be nice :D
@MrEsherbek
@MrEsherbek 6 ай бұрын
Spent time wonderfully.
@juanitoMint
@juanitoMint 5 ай бұрын
Great Explanation with a useful example, I would love to see in this particular example a way to chain multiple Notifiers in a slice!
@user-sc5pw5cw5n
@user-sc5pw5cw5n 4 ай бұрын
The video demonstrates how to refactor a simple Go application to use interfaces, highlighting the benefits of dynamic behavior and testability. Key moments: 00:01 Interfaces can be confusing for people, but using them in applications can clarify their purpose and benefits, especially for those aspiring to be Go engineers. -Creating a simple application to demonstrate interface usage can help developers understand when and how to utilize interfaces effectively. -Implementing a notification system with different methods like email, SMS, or Slack can showcase the versatility of interfaces in handling various functionalities. 03:41 The video discusses refactoring code to use interfaces, emphasizing the importance of error handling and context in Go programming. It also touches on dependency injection and state management in code design. -Importance of error handling and context in Go programming for interfaces. It highlights the significance of returning errors and using context to manage timeouts and cancellations. -Discussion on dependency injection in code design, focusing on the need for a mechanism to attach state to handlers. It explains the concept in the context of creating a struct for account handling. 07:24 The video discusses implementing an account Notifier interface in Go programming language, creating a simple account Notifier structure, and utilizing the context package for handling notifications efficiently. -Creating an instance of the account Handler and implementing the account Notifier interface for handling account notifications efficiently. -Utilizing the context package for handling notifications and demonstrating a simple implementation of account notifications in Go programming. 11:31 Using interfaces in Go can allow for dynamic and flexible code changes, as demonstrated by swapping account notifier implementations easily. It showcases the power and versatility of interfaces in Go programming. -Demonstrating how to swap account notifier implementations by passing a new implementation, showcasing the flexibility of interfaces in Go programming. -Discussing the appropriate use of interfaces in Go, highlighting the importance of interfaces for attaching state in certain implementations like API Keys or caching systems.
@rajughorai7483
@rajughorai7483 3 ай бұрын
🎯 Key Takeaways for quick navigation: 00:00 *🛠️ Interfaces in Go can be confusing for some, especially regarding when and how to use them effectively.* 01:36 *📡 Implementing a notification system after specific actions in your application is a common practice, such as notifying users or admins via various channels.* 03:42 *🔄 Refactoring code to use interfaces is beneficial for scenarios where implementations may vary, such as different notification methods.* 06:14 *⏳ When designing systems with potential IO operations, using contexts is crucial for managing timeouts and ensuring application determinism.* 08:32 *📜 Dependency injection through interfaces allows for flexible and dynamic behavior without modifying core logic repeatedly.* 11:44 *🔄 Utilizing interfaces enables easy swapping of implementations, improving code flexibility and maintainability.* 13:54 *🔥 Proper understanding and usage of interfaces in Go can lead to more idiomatic, composable, and maintainable code.*
@macot79
@macot79 6 ай бұрын
Fantastic video Anthony, thanks a lot!
@Noudapi
@Noudapi 6 ай бұрын
Hey Anthony, thanks for the great video. For a next video, would it be possible to see how you would implement storage interfaces in an API? You started something like in a previous video "how to structure a go project".
@stefanbogdanovic590
@stefanbogdanovic590 6 ай бұрын
or you can attach preference property on Account and create NotificationFactory which creates proper implemntation then you don't have to change anything just create new impl. Awesome video!
@TheMouseJerry-du1md
@TheMouseJerry-du1md 4 ай бұрын
Brilliant yet concise video.
@sondernfy
@sondernfy Ай бұрын
That was beautiful. Instantly subscribed!
@michaelrichter9408
@michaelrichter9408 6 ай бұрын
Which Rest API VS Code extension do you use? Great video. Thanks.
@LourensRolograaf
@LourensRolograaf 2 ай бұрын
I think it is Thunder Client
@sondernfy
@sondernfy Ай бұрын
@@LourensRolograaf Correct!
@Leeway4434
@Leeway4434 6 ай бұрын
I'm thinking about how to build htmx+templ forms using interfaces for different form input types. We always have value+error strings for form params--we can make an interface to fill them in programmatically. So we can define a form as a slice of FormInputType enums and have the interface implementation fill out the template with those form inputs from the slice. For example, FormInputType{UsernameInput,PasswordInput} can be passed to some form builder with the value/error params
@sefpai424
@sefpai424 6 ай бұрын
very easy to understand explanation
@coffeeintocode
@coffeeintocode 6 ай бұрын
Yeah this is great stuff. As always 🔥
@croncoder862
@croncoder862 6 ай бұрын
One question, in this video you changed the behaviour by swapping the implementation, but what if I have a few structs that carry configurations and each implementation has a different configuration. Is there a way to address that?
@ramazangCoder
@ramazangCoder 6 ай бұрын
Great!!❤ Anthony Can you show builtin golang Interface and examples for brain ruins 😄
@MT87840
@MT87840 6 ай бұрын
Thanks so much!
@cybermindable
@cybermindable 6 ай бұрын
Why is changing or creating a new notifier strictly better than modifying the handler?
@ArturdeSousaRocha
@ArturdeSousaRocha 6 ай бұрын
Anyone know what color theme Anthony is using?
@anthonygg_
@anthonygg_ 6 ай бұрын
Gruvbox
@raoulkent
@raoulkent 6 ай бұрын
Hi Anthony, really great video as always, it's much appreciated by many. I was wondering if you've got anything in the pipeline, or considered, putting out some "go gym" type videos. And by that I mean smaller exercises that people can do in order to get better. TLDR: Are you considering project suggestions as part of your content?
@walidsi71
@walidsi71 6 ай бұрын
Thanks for the video. What is the extension you use in vscode for creating http requests in a new tab to test the code?
@anthonygg_
@anthonygg_ 6 ай бұрын
Thunder client
@mayoniaise5169
@mayoniaise5169 6 ай бұрын
why make a state for an API key as the context value is made for that ?
@fullstack_journey
@fullstack_journey 6 ай бұрын
Go daddy
@wew8820
@wew8820 4 ай бұрын
a bit like strategy pattern
@sabbirhasan6934
@sabbirhasan6934 6 ай бұрын
The most confusing video on interface i've seen so far!
@fartknockers
@fartknockers 6 ай бұрын
Excited for this!
Structure Your Golang Service With Layers Like This
7:59
Anthony GG
Рет қаралды 14 М.
LeetCode 67. Add Binary (C++)
15:25
gcmaidana
Рет қаралды 27
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 76 МЛН
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 9 МЛН
МАИНКРАФТ В РЕАЛЬНОЙ ЖИЗНИ!🌍 @Mikecrab
00:31
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 41 МЛН
4Sum by a FAANG engineer | Leetcode | Live coding
12:26
Distributed Systems Programmer
Рет қаралды 42
This Will Make Everyone Understand Golang Interfaces
21:03
Anthony GG
Рет қаралды 51 М.
How To Use The Context Package In Golang?
17:03
Anthony GG
Рет қаралды 61 М.
Golang: The Last Interface Explanation You'll Ever Need
17:58
Flo Woelki
Рет қаралды 12 М.
3 Golang Tips For Beginners I Wish I Knew Sooner
13:18
Anthony GG
Рет қаралды 42 М.
How I Write an API Client in Golang (with testing)
19:52
NSURLProtocol: How I Stole an App For My Wedding
56:25
Bryce Bostwick
Рет қаралды 22 М.
So You Think You Know Git - FOSDEM 2024
47:00
GitButler
Рет қаралды 1,1 МЛН
Go Pointers: When & How To Use Them Efficiently
14:09
Anthony GG
Рет қаралды 77 М.
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 109 М.
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 76 МЛН