Learning Golang: Interface Types - Part 1

preview_player
Показать описание
Welcome! Let's learn about Go Types, specifically Interface Types, a little bit of Functions and Methods; and why all of those types are somehow interconnected.

* What is an Interface in Go?

An interface type is defined as a set of method signatures, a value of interface type can hold any value that implements those methods.

* How to implement Interfaces in Go?

Compared to other programming languages, a type implements an interface IMPLICITLY by implementing the methods; there's no need to refer to the original interface, there's no concept of "extends" or "implements". This means the actual concrete implementation of a type could appear in any other package without prearrangement.

In a future episode I will discuss more about interfaces and types in Go like:

* Empty interface "interface{}",
* nil interfaces,
* Type assertions, and
* Type switches

---

00:00 - Start
00:10 - Introduction: What is a Type (Basic/Composite) in Golang?
01:00 - Functions and Methods in Golang - Example
03:45 - What is an Interface Type?
06:66 - What about interface{}, type assertions?
07:10 - Conclusion

---

Who am I:

Hello👋🏼! I'm Mario, a Hands-on Software Architect and Lead Backend Engineer with more than 16 years of professional experience building all kinds of software including on-premise Industrial Automation Systems, Linux Accessibility Desktop and Browser Components as well as Distributed Advertising Microservices.

Every week I will share with you different topics I've learned while working for small startups and large companies including the processes I've followed over the years for successfully delivering complex enterprise systems from start to end.

Subscribe if you like Software Development, Software Architecture and Systems Design!

Keep it up. Don't give up!

#golang #microservices #programming

--- Our affiliate links below

--- Our Vlog Channel

Рекомендации по теме
Комментарии
Автор

Could you provide a real-world example of the use of an interface, such as what might be used in an e-commerce application, or a dating website, or some relatable concept? I'm still not clear on specific use-cases wherein an interface would be utilized. I find most videos on Youtube focus on intermediate to experienced programmers, so a basic "Sesame Street" style explanation would be greatly appreciated.

MrAverageViewer
Автор

if you place the interface definition next to where you use it - what happens if you want to use same interface in more than one packages, say one in cmd and one in internal folders? :)

tudorhulban
visit shbcf.ru