Fixing my Go Project Structure ("The Better Backend" V2 - Tapir App)

  Рет қаралды 16,614

Ben Davis

Ben Davis

Күн бұрын

Пікірлер: 53
@esra_erimez
@esra_erimez 2 жыл бұрын
I never clicked on a video so fast! I'm enthusiastic to see the progress.
@yazidridwan6917
@yazidridwan6917 2 жыл бұрын
realy appreciate all the great things you've done. can't wait for the future videos
@Fybuh
@Fybuh 2 жыл бұрын
I was arguing with someone on folder-by-feature. He was against it and kept making noise saying it shouldn't happen in go. I have been using fbf in all my apps properly and have never run into any issue... except with python when i struggled with cycle imports. Happy to see you paved the road for me to avoid cycle imports here
@emilianobarrionuevo7503
@emilianobarrionuevo7503 2 жыл бұрын
Great presented video. Thanks for your time and sharing the process of thinking and explaining the way you resolve and deal with the code in self. Being 39 now, I have encounter this situation many times on different projects and different teams, getting things together and make the right decisions to take the project to be in a solid foundation at start. Would love to see more videos on this journey. Thinking the way I can help out...🤔
@loubion
@loubion 2 жыл бұрын
Full newbie here, came to your chanel, tired of useless tutorial on the language. And I'm really glad to find some real world code, to hear some Go related stuff (like frameworks, architecture and tooling), and read the comments to get even more ! Poor english speaker, sorry for that but in a nutshell: thanks a lot
@bmdavis419
@bmdavis419 Жыл бұрын
Glad to help, stuff like this means a lot thank you
@j946atFIVEFOUR88AA
@j946atFIVEFOUR88AA 2 жыл бұрын
this is a really awesome channel, thanks man
@bskur6834
@bskur6834 Жыл бұрын
i mean fiber is really express like so it makes sense in my head just to organize it like an express project, this way seems overly complicated idk or maybe a mix of both would be nice, like having routes, handlers and models inside internal
@michaelangelovideos
@michaelangelovideos 2 жыл бұрын
This is actually pretty much the NestJs pattern, cool to see it in Go
@nekoill
@nekoill Жыл бұрын
Nah man, it's cool seeing an interesting useful project being iterated upon, as that too is a part of a software lifecycle
@ChillHunter
@ChillHunter 2 жыл бұрын
You do great work on youtube thank you
@RedPanda-ej2pn
@RedPanda-ej2pn 2 жыл бұрын
Thanks. I found this very useful!
@killiangrieg
@killiangrieg 2 жыл бұрын
This is really shaping up nicely. Well done. What are your thoughts regarding hexagonal architecture?
@bmdavis419
@bmdavis419 2 жыл бұрын
I have not used it, but it is on my list of things to learn more about
@dandogamer
@dandogamer 2 жыл бұрын
It's looking better Ben, I think the name of your todo package is stuttering tho. Rather than type TodoDB it would just be DB. You don't see the bytes writer method being called bytes.BytesWriter it's just bytes.Writer
@bmdavis419
@bmdavis419 2 жыл бұрын
Oh yea thats a really good point lol I did not even think of that
@JanChodorowski
@JanChodorowski 2 жыл бұрын
First stargazer! :)
@grif.n
@grif.n 10 ай бұрын
When you build your app with a Nextjs frontend are you going to communicate with your Go backend via the Next server still or directly from the browser? If communicating from Next server to Go server, do you find the extra step of browser -> server -> server to reduce performance or scalability?
@brightglitch958
@brightglitch958 2 жыл бұрын
I heard fiber uses http/fast still need to research on that, but it'd be cool a comparison on different http packages.
@Benozo17
@Benozo17 Жыл бұрын
Controllers renamed to go idio "handlers", http should be its own pkg easy to test, cmd should init http, mongo, root should have start pkg for embeds, views pkg ??, imoh each pkg should hold its own handler models, http registers your pkg handler and http routes is init in cmd, this way you only register your handler. I think your done a great job bootstrapping a minmal structure, its great for small todo like apps, i think you can take this a lot further to handle larger code base, from one gopher to another, keep Going because you will never GO back 😅, ... excuse the dry pun 😂
@JohnDoe-fe3zw
@JohnDoe-fe3zw 2 жыл бұрын
This is great, only thing I didn’t like was connecting the db instance to the controller. since a controller can sometimes make other external calls. I just wouldn’t want anyone working on that endpoint make a db mistake. My personal preference is on each model and the crud functions and in the those functions have a pointer to the db. kind of like how Ruby on Rails has it
@rumble1925
@rumble1925 Жыл бұрын
I was messing around in Go a few weeks back, I implemented the same general structure. Just think it was cool that I settled on this my first time playing around with the language, feels validating that I'm not completely dumb seeing as I'm coming from frontend and don't have much experience with any of this.
@ImreKovács-p6g
@ImreKovács-p6g Жыл бұрын
Great video! I've decided to give this project structure a try. If you wanted to expand this app with, let's say, a "calendar" or whatever, would you create a nother folder named "calendar" in the folder named internals, at the same level as todo, and in the "calendar" folder, would you have the files "controller.go", "storage.go" and "router.go"?
@rajenderkatkuri7642
@rajenderkatkuri7642 Жыл бұрын
Dude what's your VS Code Theme? Looks sick.
@viniciusataidedealbuquerqu2837
@viniciusataidedealbuquerqu2837 2 жыл бұрын
9:45 A good thing I try to do is to create a context structure that carries all the application dependencies and every function that uses that context is instantiated as a implementation of that structure (like every request method)
@viniciusataidedealbuquerqu2837
@viniciusataidedealbuquerqu2837 2 жыл бұрын
oh you figured that out in 12:40
@abdirahmann
@abdirahmann 2 жыл бұрын
btw, it would be awesome if you made a video on how you monitor your backends and aggregate analytics to detect and respond to anomalies. Thanls
@ftamas88
@ftamas88 Жыл бұрын
Recommend using context for the app shutdown :)
@ahmeism90
@ahmeism90 Жыл бұрын
hey im happy that i found your channel, as TS developer, i was trying to learn golang but there were no too many resources. I have and app idea and i have already done some backend part. Would you like to make a video for nodejs developers who want to jump in golang?
@bmdavis419
@bmdavis419 Жыл бұрын
That is a good idea, a 1 to 1 of major concepts, will add it to the list!
@hectorcast943
@hectorcast943 Жыл бұрын
What is the vscode theme
@MosiurRahman-dl5ts
@MosiurRahman-dl5ts 2 жыл бұрын
Have you looked at Pocketbase project structure?
@OldKing11100
@OldKing11100 2 жыл бұрын
One thing I noticed in the Fiber Documentation was the ⚡Make Fiber Faster. It sounds like the standard JSON parser is slow, but they list a bunch of them. I settled on bytedance/sonic since it's optimized with C and Assembly. Is using sonic a bad move or should I use one of the other recommended JSON parsers? This seems like an easy way to reduce stress on the server.
@OldKing11100
@OldKing11100 2 жыл бұрын
Of course the moment I consider this Go 1.20 comes out with a 30% increase in performance to the standard JSON encoder.
@richardamare3575
@richardamare3575 2 жыл бұрын
what if I want to create something like service struct for uploading images to GCP? should I just create another file for example internal/todo/service.go and implement the feature there and then just pass it to the controller the same way as the todo storage?
@ruyvieira104
@ruyvieira104 2 жыл бұрын
No, you just don't use that structure at all. Just make a single file and make it run.
@ericjhuneespa3381
@ericjhuneespa3381 2 жыл бұрын
have you try go-chi?
@Mixesha001
@Mixesha001 2 жыл бұрын
You should try go-chi :)
@bmdavis419
@bmdavis419 2 жыл бұрын
It looks really cool, todays video will probably be a first impressions video!
@oussamasethoum1665
@oussamasethoum1665 2 жыл бұрын
make a video on go and docker
@viniciusataidedealbuquerqu2837
@viniciusataidedealbuquerqu2837 2 жыл бұрын
go really needs a DI library, doing this manually is gonna get boring fast
@viniciusataidedealbuquerqu2837
@viniciusataidedealbuquerqu2837 2 жыл бұрын
oh google already created one called wire. I should check that out
@liamkiggen
@liamkiggen 2 жыл бұрын
Drop fiber and add chi
@ghostofalexandria8914
@ghostofalexandria8914 Жыл бұрын
Why should he do that?
@markovidakovic6584
@markovidakovic6584 Жыл бұрын
Fiber, fasthttp, and many other alternative frameworks have numerous pitfalls: - You get stuck into the fiber ecosystem. There is no standard library compatibility with their router and api. - Fiber's marginal speed gains are only going to help you in a specific niche that 0.1% of people will have. - To get the full benefit of Fiber, it requires an unidiomatic and advanced style of Go programming. Generally speaking, your bottleneck with your http applications is not going to be memory or CPU usage in most situations. Instead, it's going to be network time, database access, and other IO tasks and operations. The amount of time your HTTP router spends processing a request is tiny compared to most other tasks. The vast majority of Go frameworks can be pretty easily picked up in an hour or so. Typically, the extent to what you have to learn is the different names they use for the same concepts you should already be familiar with. That being given, if you have the choice, this is generally unnecessary if your goal is to build an API service. The Go standard library interface (alongside a router, like chi or gorilla/mux) generally suffice. Why chi specifically? - It's quite purpose-built. It does one thing, and it does it well. - It's fully compatible with the Go standard library, making it usable with almost any other dependency you might have. - It's a very small addition for the power and functionality it provides, with a relatively small API surface.
@PatFarrellKTM
@PatFarrellKTM Жыл бұрын
I've watched this and your version from two weeks ago. You keep using the term "todo" as a buzzword. I don't understand what, exactly, you mean by it. I would think that a todo list might have stuff like "1) design dbms schema, 2) figure out verbs in POST/GET commands, 3) implement them 4) drink beer"
@SatishRamteare
@SatishRamteare Жыл бұрын
why not GIN?
@dinoscheidt
@dinoscheidt Жыл бұрын
I’m sure I come across as rude, but why replace TypeScript with Go which (except for GOs lack of type hierarchies) are pretty similar and lose code, interface, validation, type, state and knowledge sharing - homogeneity - to the client? I’d understand if this would be F#, Haskell, Lisp,… due to complex event sourced processing or so but… for a web server? NestJS (not next) would be a good reference point
@ejaz787
@ejaz787 Жыл бұрын
Performance + so much more
@alkolaqi83
@alkolaqi83 Жыл бұрын
This is one of the reasons I stay away from languages like go or rust. The js world is full of frameworks and good/bad patterns. I do like golang a lot and your vids will help more people use the language. Please keep posting these vids.... also it will be nicer to avoid writing all the swagger docs, is there way to generate the docs automatically based on the types
@bmdavis419
@bmdavis419 Жыл бұрын
With swagger you have to manually go through and define everything, its annoying, but will make the FEs life so much easier
@brightglitch958
@brightglitch958 2 жыл бұрын
I was waiting for this, niceee 🤍
Why I'm learning Go
21:35
Web Dev Cody
Рет қаралды 72 М.
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
The BEST Tool to Structure Golang Projects
7:58
Melkey
Рет қаралды 47 М.
Svelte 5 Ruined Svelte (and that's why I love it)
12:37
Ben Davis
Рет қаралды 14 М.
Build a Microservice with Go #1 - Getting Started
16:19
Net Ninja
Рет қаралды 62 М.
Build an Async API in Golang (part 12 - SQS Worker)
24:00
How I Structure New Projects In Golang
21:32
Anthony GG
Рет қаралды 68 М.
This Is The BEST Way To Structure Your GO Projects
11:08
Melkey
Рет қаралды 89 М.
Golang pointers explained, once and for all
13:49
JamieGo
Рет қаралды 10 М.
Building a CLI application with Golang
12:31
cdruc
Рет қаралды 47 М.
Why use a monorepo?
6:32
Vercel
Рет қаралды 110 М.
Structure Your Golang Service With Layers Like This
7:59
Anthony GG
Рет қаралды 16 М.