How To Refactor A Golang Project By Using Interfaces

  Рет қаралды 13,842

Anthony GG

Anthony GG

Күн бұрын

► Join my Discord community for FREE education 👉 / discord
► Become a Patreon for exclusive tutorials 👉 / anthonygg_
► Follow me on Twitter 👉 / anthdm
► Follow me on GitHub 👉 github.com/anthdm
In this Golang tutorial, I will teach you how you can refactor a Golang project with the use of interfaces.
#golang

Пікірлер: 22
@anthonygg_
@anthonygg_ Жыл бұрын
► Join my Discord community for free education 👉 discord.com/invite/bDy8t4b3Rz ► Become a Patreon for exclusive tutorials 👉 www.patreon.com/anthonygg_ Thanks for watching
@jondoe79
@jondoe79 Жыл бұрын
You can use space separated tags `bson: "fact" json:"fact"` Documentation says: By convention, tag strings are a concatenation of optionally space-separated key:"value" pairs. Each key is a non-empty string consisting of non-control characters other than space (U+0020 ' '), quote (U+0022 '"'), and colon (U+003A ':'). Each value is quoted using U+0022 '"' characters and Go string literal syntax.
@anthonygg_
@anthonygg_ Жыл бұрын
You are my hero 🙏
@Cethris
@Cethris 9 ай бұрын
"This is going to be nice and thick for the blind homies" I nearly choked
@TheWorpler
@TheWorpler Жыл бұрын
Just found you and subbed. Moving to use Go on some personal projects rather than Python.
@anthonygg_
@anthonygg_ Жыл бұрын
Welcome to the club!
@donovanvanderlinde3478
@donovanvanderlinde3478 Жыл бұрын
Lol I just blew all my money for December 😂 But now I know which Patreon to sub to in Jan … your content is insane
@anthonygg_
@anthonygg_ Жыл бұрын
Thanks my man!
@rekram1519
@rekram1519 Жыл бұрын
I was hoping youd make this type of video, perfect!!!
@tpotjj2979
@tpotjj2979 Жыл бұрын
Interfacer all the way🚀
@salman0ansari
@salman0ansari Жыл бұрын
finally found a good gotuber 😮‍💨
@hananasyrawi5206
@hananasyrawi5206 Жыл бұрын
Yeah Power of Type Duck
@lviv255
@lviv255 Жыл бұрын
Interface still has the CatFact as an arg. An interface should not have any reference to concrete types else it defeats the main advantages of using it.
@JustValxntine
@JustValxntine Жыл бұрын
What's the other option here? CatFact is a type that we own and control, not a dependency
@ZockaRocka
@ZockaRocka 10 ай бұрын
Hey :) I am sure you answered the question a lot of times, but i would like to know which Font and Theme do you use? thanks in advance! Great Vid!
@dmitriigoriunov9018
@dmitriigoriunov9018 Жыл бұрын
HI Anthony, really love your videos, just found the channel today been going to quite a few How To Golang videos and find it very helpfull! I was actually wondering how would you approach an API design that requires you to do partial update, and been able to reset the value of some fields: For example lest say we have the CatFacts struct that looks like type Fact struct { ShortForm string LongForm string } type CatFact struct { Fact Fact Length int } Let say I would call the api to create the fact like POST {fact: { shortForm: "one", longForm: "super long form"}, length: 20 } But then later I want to update the fact with PATCH {fact: { shortForm: "two", longForm: "super long form"}} and again update it with PATCH {fact: null} or update just Length PATCH {length: 1000} This is just an example but I would really like to know how would you structure your structs and application for this cases, I know that golang treats null and no value the same so it becomes trickier to set value to Null, also the null packages do not support non primitive types. Would really appreciate your help!
@pedrohenriquebufulindealme5763
@pedrohenriquebufulindealme5763 Жыл бұрын
Great Video. I was wondering, what if you want to have multiple different collections for MongoStorer? For example, a "facts" collection and a "breeds" collection in this case. Could I compose my interface by kind of creating a repository pattern? Where I Have multiple interfaces inside my MongoStorer where each one have it's GetById, Update... for that specific collection?
@anthonygg_
@anthonygg_ Жыл бұрын
Thats possible!
@failist9570
@failist9570 Жыл бұрын
Came here from reddit. Stayed here for content.
@shayannadeem321
@shayannadeem321 Жыл бұрын
Can you create a video that tells how to use interface with 2 or 3 different type of structs as if you have multiple structures the interface will have multiple CreateAccount, CreateCatfact and methods for each type of struct ? can we use interface{} or any in interfaces ?
@Cruzylife
@Cruzylife Жыл бұрын
can u push this to your github
@murodiskandarov2431
@murodiskandarov2431 11 ай бұрын
no comment
I Created GoFiber 7 Years Ago But Is It Faster?
18:46
Anthony GG
Рет қаралды 10 М.
A Practical Example How To Use Interfaces In Golang
14:42
Anthony GG
Рет қаралды 24 М.
Angry Sigma Dog 🤣🤣 Aayush #momson #memes #funny #comedy
00:16
ASquare Crew
Рет қаралды 50 МЛН
ПРИКОЛЫ НАД БРАТОМ #shorts
00:23
Паша Осадчий
Рет қаралды 5 МЛН
Секрет фокусника! #shorts
00:15
Роман Magic
Рет қаралды 105 МЛН
STOP! This Is How You Structure Golang Applications
22:04
Anthony GG
Рет қаралды 21 М.
This Will Make Everyone Understand Golang Interfaces
21:03
Anthony GG
Рет қаралды 51 М.
Everything You Need To Know About Pointers In Golang
20:47
Anthony GG
Рет қаралды 29 М.
Golang's Mocking Techniques - Kyle Yost | hatchpad Huddle
41:20
What Makes Golang Go: The Power of Go Interfaces - Ricardo Gerardi
52:42
ChariotSolutions
Рет қаралды 13 М.
How You Should Use Mutexes And Atomic Values In Golang?!
15:49
Anthony GG
Рет қаралды 14 М.
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 108 М.
Golang: The Last Interface Explanation You'll Ever Need
17:58
Flo Woelki
Рет қаралды 12 М.
Master Golang with Interfaces
21:54
Kantan Coding
Рет қаралды 13 М.
Testcontainers have forever changed the way I write tests
12:11
Dreams of Code
Рет қаралды 117 М.
Angry Sigma Dog 🤣🤣 Aayush #momson #memes #funny #comedy
00:16
ASquare Crew
Рет қаралды 50 МЛН