How To Structure Your Golang (API) Projects!?

  Рет қаралды 46,119

Anthony GG

Anthony GG

Күн бұрын

► Join my Discord community for free education 👉 / discord
► Become a Patreon for more exclusive content 👉 / anthonygg_
► Buy my a coffee 👉 donate.stripe.com/aEU2a6ayH2u...
► Follow me on Twitter 👉 / anthdm
► Follow me on GitHub 👉 github.com/anthdm
In this Golang tutorial, I will show you MY best practices on how to structure your Golang (API) projects.
#golang

Пікірлер: 68
@anthonygg_
@anthonygg_ Жыл бұрын
► Join my Discord community for free education 👉 discord.com/invite/bDy8t4b3Rz ► Become a Patreon for exclusive tutorials👉 www.patreon.com/anthonygg_ ► Buy me a coffee 👉 donate.stripe.com/aEU2a6ayH2uCa3u4gg Thanks for watching
@TheRealisticNihilist
@TheRealisticNihilist Жыл бұрын
I love the way this guy says "structure".
@scarthebadguy
@scarthebadguy Жыл бұрын
Hey mate these are great videos. I love how verbose you are as you type. I learn more from you talking than I have from any udemy course
@krislui852
@krislui852 10 ай бұрын
just learnt go recently and trying to build my first project on it. tried different ways to structure my project but found them being quite messy. great video, helps a lot.
@mwnkt
@mwnkt Жыл бұрын
loving the consistency in uploads, loving the channel so far
@linhnguyen05111999
@linhnguyen05111999 4 ай бұрын
omg amazing! I really needed this. Great example, especially the storage interface.
@Leon-cj8hd
@Leon-cj8hd Жыл бұрын
Your coding speed is insane, even while talking. Viewed some videos, I think the content is great, thanks a lot :)
@Incolent
@Incolent Жыл бұрын
Just stumbled upon your channel. Amazing content for students! Keep it coming!
@anthonygg_
@anthonygg_ Жыл бұрын
Welcome aboard!
@pss_crs
@pss_crs Жыл бұрын
I'm regretting notvdiscovered this channel early thanks.
@joshb7001
@joshb7001 Жыл бұрын
You are pumping out golden eggs non stop. Thank you
@jondoe79
@jondoe79 Жыл бұрын
Super clean, it's grouped by feature.
@davidhtorres
@davidhtorres Жыл бұрын
These videos are awesome! Thank you! Very clear!
@Shatterhand16
@Shatterhand16 Жыл бұрын
Watched your "Important Tips On How To Write Idiomatic Code In Golang" just before watching this, and I believe that the interface declared in 8:02 should be Storer instead of Storage, same for module name. Additionally maybe it would be worth to enable screencast mode in vscode with smaller font and offset? I think it'd be great to learn some of the shortcuts that allow you to be that fast just by watching. By the way loving the content, keep it up!
@anthonygg_
@anthonygg_ Жыл бұрын
Yeah storer would maybe more idiomatic. You are right.
@jean-naymar602
@jean-naymar602 11 ай бұрын
This is a common misconception but the "effective go" doc does NOT say that every interface should end in -er. Instead, it says that IF an interface defines only 1 method, then this interface should be named by appending -er to the method's name : "By convention, one-method interfaces are named by the method name plus an -er suffix" That's it. (Admittedly, one method interfaces should be what you aim for anyway but still, you shouldn't bother naming multi-method interfaces with -er...)
@Shatterhand16
@Shatterhand16 11 ай бұрын
@@jean-naymar602 That's cool to know, thanks for detailed explanation!
@andreimikhalkevich5633
@andreimikhalkevich5633 Жыл бұрын
go ahead Anthony, very helpful skills
@tintin537
@tintin537 Жыл бұрын
Thank you. as always superb.
@terriprifti5069
@terriprifti5069 Жыл бұрын
This is a gem 💎
@blazinglyfaster9935
@blazinglyfaster9935 Жыл бұрын
Perfect timing 🚀🚀🚀
@JohnDoe-ji1zv
@JohnDoe-ji1zv Жыл бұрын
Anthony thanks for the video! Would like to get your opinion on di frameworks like Uber fx. Do you use dependency injection frameworks in your applications ?
@ThePandaGuitar
@ThePandaGuitar Жыл бұрын
I don't know Go and that flag string is awesome. I can see why making CLIs in Go is sweet.
@frozenn00b
@frozenn00b 8 ай бұрын
Breaking all the Golang project structure conventions for "reasons". Convention is to use cmd, internal, pkg, test for sorting your packages... arbitrary folder structures introduce additional hurdles for newcomers to the project to figure out what you're doing.
@Noudapi
@Noudapi 4 ай бұрын
Hey Anthony thank you for your video. I just don't understand how you implement the storage interface. Do you add all the functions to implement for all entities of your database?
@cothromachd
@cothromachd Жыл бұрын
anthony the sigma
@anonymous-sk9li
@anonymous-sk9li 25 күн бұрын
Sir can you make a tutorial on function being define inside a interface why it is necessary and how to use it and also on method receiver where and where not to use it . Your content is always quality worth it will be great help for noob developers like me
@JanPhilippHeinrich
@JanPhilippHeinrich Жыл бұрын
Hey Anthony, basically this is a good video but could you explain why you put the interface for store right there where it is implemented? I learned that we use duck typing / structural typing which means we would put the interface were it is used.
@anthonygg_
@anthonygg_ Жыл бұрын
In have a video explaining interfaces and why you should use them
@rafaelcordoba13
@rafaelcordoba13 Жыл бұрын
How would you organize all the other go files based on application features? For a game server for example, you have a shop, daily quests, daily login, clans, events, wallet, etc. How do you see that scaling?
@anthonygg_
@anthonygg_ Жыл бұрын
Just separate handlers, data, and business logic
@jorisjansen2892
@jorisjansen2892 Жыл бұрын
🚀🚀
@andrewcathcart
@andrewcathcart Жыл бұрын
Random, but can you export your vscode setup? Theme looks v clean
@anthonygg_
@anthonygg_ Жыл бұрын
github.com/anthdm/vscode-config
@nickchristoforidis6176
@nickchristoforidis6176 Жыл бұрын
Hello Anthony, A while ago, I just watch the "How To Build And Structure A JSON API Project In Golang!?" video, in which you're following a sightly different approach concerning the folders/packages structure (which I love very much BTW). "Everything on root" you're saying, "unless it's really needed". I'd like to ask you why? Does this happen because the videos are from different time? Thank you.
@anthonygg_
@anthonygg_ Жыл бұрын
My personal opinion is to keep things very simple and with as less folders possible. Because soon or later you will end up with circular dependencies. But I know that this is very hard for a lot of people to switch to due to the fact that the meta is to folderize like a mad men. So, I try to switch things up and give people multiple approaches on "how they could structure Golang applications".
@nickchristoforidis6176
@nickchristoforidis6176 Жыл бұрын
@@anthonygg_ Got it! I'm just starting and I'm friend of the minimalistic approach. You've right though.
@soufta5872
@soufta5872 9 ай бұрын
Hi there. Is golang a good thing for sysadmin and autmation projects ? I don't want to use python especially when it comes to third party librairies that are hard to install on production ! Thanks
@maximilianlang7175
@maximilianlang7175 Жыл бұрын
If you have more than one route, maybe something like /users and /books. Would you implement one store for all or would you have one store for all your types?
@anthonygg_
@anthonygg_ Жыл бұрын
Depends. You could make more interfaces for each domain if you want. Otherwise your storage interface will be a raidboss
@maximilianlang7175
@maximilianlang7175 Жыл бұрын
@@anthonygg_ Thanks! So you would have a user and a book interface and then several implementations for mongo oder mysql
@anthonygg_
@anthonygg_ Жыл бұрын
@@maximilianlang7175 Yes. UserStorage, bookStorage and so on.
@maximilianlang7175
@maximilianlang7175 Жыл бұрын
@@anthonygg_ and do you plan to make a video about mongo?
@anthonygg_
@anthonygg_ Жыл бұрын
@@maximilianlang7175 good idea, will note that.
@jed271
@jed271 Жыл бұрын
What are your thoughts on hexagonal architecture?
@anthonygg_
@anthonygg_ Жыл бұрын
Thats a scam
@jed271
@jed271 Жыл бұрын
@@anthonygg_ can you elaborate more? I really like your contents
@anthonygg_
@anthonygg_ Жыл бұрын
@@jed271 I think that people are inventing new ways of doing things because they have nothing better to do. My advice is to just solve the problem and do what works for you. The folder structure I showed you worked very well for me and I think it's a structure that is also highly adopted by a lot of big open-source projects. Don't make it too complex.
@kamalkamals
@kamalkamals Жыл бұрын
so the storage it s look like session of connection to mongodb, but is that a best practice to inject it as params in every function of the services ?? why no use it like a global variable !
@anthonygg_
@anthonygg_ Жыл бұрын
Yup. Im using that approach right now.
@kamalkamals
@kamalkamals Жыл бұрын
@@anthonygg_ greate i use with graphql and works good, are u test before upload file with graphql ?? sorry if that is not the topic of this video
@pavelastraukh9905
@pavelastraukh9905 10 ай бұрын
Is there a reason why store is passed by value and not by reference?
@MaheshKumar-tc3gn
@MaheshKumar-tc3gn 4 ай бұрын
Do you keep everything in server package. Server package will handle user requests, in future it will handle all the separate modules? I think it is bad idea and bad structure
@insert-name1500
@insert-name1500 Жыл бұрын
What's the name of this VS Code theme?
@anthonygg_
@anthonygg_ Жыл бұрын
Gruvbox
@bmitch3020
@bmitch3020 Жыл бұрын
"package util" oh no, Oh no no no no no.
@2gbeh
@2gbeh 5 ай бұрын
🇳🇬 Is Go a high level language ? This syntax looks sick (in a bad way).
@hello-test-user
@hello-test-user Жыл бұрын
make : The term 'make' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
@pedrohenriquebufulindealme5763
@pedrohenriquebufulindealme5763 Жыл бұрын
Do you have any video that extends on the Storage pattern you showed?
@anthonygg_
@anthonygg_ Жыл бұрын
Hmm. Not sure. I use it in a lot of streams and projects
@gustavogoncalves2101
@gustavogoncalves2101 Жыл бұрын
At interface storage can we make a gerenic interface with the default CRUD methods to work with N models?
@Laflamablanca969
@Laflamablanca969 Жыл бұрын
Yes. Use generics for this.
@VeereshPatel15
@VeereshPatel15 Жыл бұрын
Hi bro, how to learn golang --->>>Please explain learning path about golang & solidity -- >>>> how to learn / build /test/ deploy frontend for web 3 projects
@faizulla5838
@faizulla5838 4 ай бұрын
A lot off Bla Bla Bloa ... "How To Structure Your Golang (API) Projects!?" , but just 3 min about structure .... why need in this video inside the file? 20 min video will good talk mi 15 min about folders and fills but not about insite the file.
@rezaneyrami7944
@rezaneyrami7944 7 ай бұрын
Hello . I wish you would speak more slowly. I can hardly communicate with your language. If possible, speak more slowly... Thank you
@samess_
@samess_ Жыл бұрын
Please create a cli app that generates the template of your structured project...🥲
@Gertozzz
@Gertozzz Жыл бұрын
When are you going to code a Shalien server? Request.get.go
@anthonygg_
@anthonygg_ Жыл бұрын
Thats a BIG task
How You Should Use Mutexes And Atomic Values In Golang?!
15:49
Anthony GG
Рет қаралды 13 М.
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Рет қаралды 102 М.
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 30 МЛН
Получилось у Миланы?😂
00:13
ХАБИБ
Рет қаралды 6 МЛН
Пранк пошел не по плану…🥲
00:59
Саша Квашеная
Рет қаралды 7 МЛН
How to create your Golang APIs from now on with v1.22
12:51
👑 Numeric literals - The Nim Manual 📖
4:18
Xkonti
Рет қаралды 53
How I Structure New Projects In Golang
21:32
Anthony GG
Рет қаралды 55 М.
This Is The BEST Way To Structure Your GO Projects
11:08
Melkey
Рет қаралды 69 М.
How To Setup A Golang + Templ Project Structure
31:20
Anthony GG
Рет қаралды 49 М.
Don't Make this Golang Beginner Mistake!
8:57
Anthony GG
Рет қаралды 21 М.
Use Docker for Your Golang Projects with Live Reloading
6:34
STOP! This Is How You Structure Golang Applications
22:04
Anthony GG
Рет қаралды 21 М.
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 30 МЛН