How To Build A Complete JSON API In Golang (JWT, Postgres, and Docker) Part 1

  Переглядів 97,493

Anthony GG

Anthony GG

Рік тому

In this series, I will teach you how to build a complete industry-ready JSON API project in Golang with JWT authentication, Postgresql, and Docker. We are going to build a bank API and build everything from scratch with only the mandatory packages we actually need. We are also going to write tests for each of our HTTP handlers. If you want to learn Golang or Rust consider subscribing to my channel so you can become a high-value engineer.
This golang tutorial is something for you if you are willing to learn about Golang testing, Golang project structure, and how to use Docker with Golang.
📢 I am also building a Discord community! Feel free to join if you are willing to learn about blockchain, web3, Defi, and quantitative trading. Or just hang out and chat.
/ discord
► Support me on PATREON and get access to exclusive lessons, tutorials, and LIVE streams
/ anthonygg_
► Join my Discord community for free education
/ discord
► Follow me on GitHub
github.com/anthdm
► Follow me on Twitter
/ anthdm
#golang #docker

КОМЕНТАРІ: 129
@anthonygg_
@anthonygg_ Рік тому
👉 Join the Discord community for blockchain, distributed systems, Golang, and Rust education: discord.gg/bDy8t4b3Rz 👉 Support me on Patreon for even more exclusive videos, vlogs, and tutorials: www.patreon.com/anthonygg_ The code can be found on GitHub: github.com/anthdm/gobank Thanks for watching
@scalitics
@scalitics 3 місяці тому
Hallo Anthony, bedankt voor deze training, dankzij jou heb ik Golang ontdekt en ik heb er echt van genoten. Je doet het heel goed en je bent een goede leraar, ook Belg, dat is een plezier! Tot ziens in de laatste aflevering!
@user-jp5oi1cl4t
@user-jp5oi1cl4t Рік тому
Anthony you are awesome in teaching golang on youtube we need more contect about golang especially projects like that Thanks again for your big and helpful effort
@bhutunga
@bhutunga 4 місяці тому
Thanks for the video, much appreciated. Learning go, so seeing someone work from scratch is more useful than you would believe!
@Jam-ht2ky
@Jam-ht2ky 9 місяців тому
this tutorial was unbealiaveble. The amount of things you managed to fit in one 30 min videos! thank you
@anthonygg_
@anthonygg_ 9 місяців тому
💪
@shleebeez
@shleebeez Рік тому
i like how you pointed out your usage of a decorator so we can use our handler as an http one without explicitly modifying it. you should keep pointing out useful patterns and such like that, it's very helpful
@terriprifti5069
@terriprifti5069 Рік тому
This video is a clear example of "from 0 to hero in 30 mins"
@MrCleverOnion
@MrCleverOnion 3 місяці тому
Kissass
@techwithed1937
@techwithed1937 11 місяців тому
This is the best go API tutorial I've ever watched. Thank you so much for your awesome content and for teaching us the best practices 🔥
@manasvi4586
@manasvi4586 11 місяців тому
Best channel for golang especially backend thank you sir
@calapranzee
@calapranzee 8 місяців тому
These videos are incredible. Thank you. :)
@AlexTitarenko87
@AlexTitarenko87 7 місяців тому
Love the style and the approach to teaching. Excellent stuff, please keep it up
@BigBrainHacks
@BigBrainHacks 2 місяці тому
Jij bent echt een baas man! Ik kan uren naar je nuchtere video's kijken man. Petje af!
@anthonygg_
@anthonygg_ 2 місяці тому
Ha! Thanks !
@rizwansworld
@rizwansworld 5 днів тому
Thanks man. Hands-on content 🤘
@sovrinfo
@sovrinfo Рік тому
Great content. Thanks!
@iliasf2415
@iliasf2415 7 місяців тому
echt een held je bent toch uit België ik hoor het aan sommige woorden ben goed met veel talen maar probeer nu go lang te leren en deze tutorial heeft hard geholpen
@saudchaudry2662
@saudchaudry2662 6 місяців тому
Man! you are the Top G of Golang
@arpitsingh9198
@arpitsingh9198 3 місяці тому
Thankyou for a Gin free API development tutorial
@caiocesarmelolopes2156
@caiocesarmelolopes2156 8 місяців тому
Amazing video, so informative, I like your rhythm and enthusiasm, congrats from Brazil xD
@annusingh4694
@annusingh4694 Рік тому
Your content is so powerful! Very helpful in terms of quality and speed. I'm learning so much at such high speed. Plus the teaching style is engaging, you make the students think which is way better than a scripted tutorial. Thank you so much 😊
@anthonygg_
@anthonygg_ Рік тому
Thank you ❤️
@blazkowicz666
@blazkowicz666 Рік тому
Hey King, you dropped this 👑
@ahmedalsaedi3849
@ahmedalsaedi3849 8 місяців тому
thank you for this super valuable appreciate the hard work here
@seymour_videos
@seymour_videos 6 місяців тому
Great video!
@abov1793
@abov1793 Рік тому
amazing 🚀
@miroslavbekyarov
@miroslavbekyarov 7 місяців тому
this is just epic, love the Bob Ross references
@gideonidowu8271
@gideonidowu8271 Рік тому
Your teaching style is second to none!
@anthonygg_
@anthonygg_ Рік тому
Thanks my man!
@arkadiuszswioko8583
@arkadiuszswioko8583 Рік тому
im glad i found your channel!
@anthonygg_
@anthonygg_ Рік тому
🤝
@ezequielrango4055
@ezequielrango4055 Місяць тому
thank you for this tutorial! is excelent and help me :D
@AndresVelasquezHenao
@AndresVelasquezHenao Рік тому
Awesome!
@AndresVelasquezHenao
@AndresVelasquezHenao Рік тому
And yeah, you're freaking fast! :D
@asutoshpanda1508
@asutoshpanda1508 Рік тому
please collect all your projects into respective playlist, it's really difficult figure out which video belongs to which project all streamed video projects, recorded projects with proper naming convention(part-1,2,3 etc) and if all could be accessible from playlist button then that will be really helpful. hope you will get some time to do this housekeeping activity Anthony. thanks for all the efforts Anthony, you have created energy and interest in me to learn golang.
@anthonygg_
@anthonygg_ Рік тому
Will do this over the weekend. Thanks for the feedback
@user-vh7te8xo8e
@user-vh7te8xo8e 3 місяці тому
great stuf!
@fahrican9708
@fahrican9708 10 місяців тому
Would be amazing if Unit Tests would be also covered
@manee427
@manee427 6 місяців тому
Really valubale and High quality content . Just one thing please : can you make the code font just a bit bigger to be easier to see ?
@AbhishekKumar-kk6qs
@AbhishekKumar-kk6qs 4 місяці тому
for 24:29, You can just select the option of JSON in postman, It will show the data in JSON format.
@ruslangabitov5202
@ruslangabitov5202 11 місяців тому
Hello,. Thank you for your content it's very interesting. I see that all your project you start with Makefile. On some of your videos I saw the MS Windows start button. Which make do you use?
@kirakira160
@kirakira160 Рік тому
You are from gold man!💪
@anthonygg_
@anthonygg_ Рік тому
Thank you.
@cyacyi779
@cyacyi779 9 днів тому
Request, make video like this again please.,, it beautiful
@tpotjj2979
@tpotjj2979 Рік тому
Moving too fast, can't keep up with all the great content Anthony is creating.🚀🔥
@anthonygg_
@anthonygg_ Рік тому
Lightning speed
@blazinglyfaster9935
@blazinglyfaster9935 Рік тому
High value content at the speed of light
@InvincibleMan99
@InvincibleMan99 11 місяців тому
Speed is good. You can always pause :)
@user-sd2ry4xy4d
@user-sd2ry4xy4d 3 місяці тому
Hey Anthony, great great work, I leaned a ton! so thank you :) I have a question tho, you created this interface `Storage` which is passed to the apiServer struct, which is good, but now If I want to add another path say (/products), I will need to create the handle funcs for the product, but then the interface won't work anymore because it's just for the accounts. How create a general interface that can implement all handlefuncs of different business logics Thank you :)
@bardus_hobus
@bardus_hobus 10 місяців тому
Would be nice to hear your recommendations now that mux is no more
@bsalstha
@bsalstha Рік тому
Please make a tutorial with rust+axum for same project.
@whimahwhe
@whimahwhe 8 місяців тому
Hey , didn't know Johnny Sins was also a developer Jokes aside, awesome tutorial man, I'm getting started with go an seeing you gliding through helped me a lot with the understanding of the language
@anthonygg_
@anthonygg_ 8 місяців тому
Johnny is a versatile actor
@swapCode
@swapCode 3 місяці тому
To solve the JSON content format you have to set headers before writing ```go w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) ```
@Prostopravda
@Prostopravda 7 місяців тому
Hello Anthony, thanks for the tutorial! BTW are you Turkish? My assumption in based on your soft pronunciation of `R`s in word endings, am I right?
@psycodreamcx7739
@psycodreamcx7739 Рік тому
Thanks for your content! One question I have, is there a reason in the handlers to return a reference (&Account{}) instead of just Account{}?
@anthonygg_
@anthonygg_ Рік тому
Maybe we need to update state. Maybe
@agaitan026
@agaitan026 4 місяці тому
so Go is better for rest api or Rust? thank you
@adhdadventure
@adhdadventure 12 днів тому
Awesome tutorial. How can i implement authentication in this api. a sign in and sign out route.
@shaileshdubey7197
@shaileshdubey7197 Рік тому
please also include nosql database too..thank you for starting this.
@anthonygg_
@anthonygg_ Рік тому
We will set the project up so that adding new types of storage can be implemented easily!
@arieheinrich3457
@arieheinrich3457 Рік тому
Thanks for this great guide ! If you had to redo this with a differernt router than Mux, that is no longer maintained, which would you have chosen and why ?
@anthonygg_
@anthonygg_ Рік тому
Echo. Because I use this.
@TedoHamTole
@TedoHamTole Рік тому
Hi Anthony thanks for the video I got one question. You mentioned about circular dependency and no need to create multiple folders/packages. So how do you structure your code is some architecture like (clean, hexagonal) recommended in Go? Or what do you suggest let's say you are handling big project. I really appreciate if you just give me some comment on it. Thanks.
@anthonygg_
@anthonygg_ Рік тому
Hi! My rule of thumb is to only create packages when you need to, otherwise, just keep things in the root folder. Think about this, if you have 100 files in separate packages or 100 files sitting in the root folders, you will still end up with 100 files right? Also, your program will not run better or faster with more packages. It is just an ancient old scam by people that have no value to bring to the table, so they try to trick you with some "architectural" bullshit. Look at the Redis codebase, for example, that is being used by millions of companies in production. All files live in the src folder. I hope this answer helps you!
@AskarSabyrov
@AskarSabyrov 7 місяців тому
I thought Johny Sins has started teaching programming 😂 Although, very useful tutorial, thanx a lot!
@Harchit23
@Harchit23 3 місяці тому
can you further explain why you decided to make a wrapper api function? did you just not want to handle the error in each different account handle function and rather handle it in one location?
@ridwanulhoque6959
@ridwanulhoque6959 2 місяці тому
OMG!
@GabrielRodrigues-sm3dr
@GabrielRodrigues-sm3dr 7 місяців тому
Really good content! I'd like to know what is your code editor theme. ✌
@anthonygg_
@anthonygg_ 7 місяців тому
Gruvbox
@tjoepoe
@tjoepoe 10 місяців тому
I just started to learn Golang from a crash course before this, but the naming is confusing to me. There is apiFunc, ApiError and APIServer? the explanation is clear though.
@iamgordonsmith
@iamgordonsmith 5 місяців тому
Amazing content this is really useful stuff. I have genuine question regarding makeHTTPHandleFunc - we describe this is a decorator but it was my understanding that with a decorator the interface doesn’t change, only the behaviour, does that make this func more of an adapter? If not, is this concept different in Golang? Thanks!
@anthonygg_
@anthonygg_ 5 місяців тому
Maybe “higher order function” would be the correct term. Not 100% sure. I tempt to not focus on terminology but on practical implementations
@Senai
@Senai 7 місяців тому
Amazing video but you should ditch make for go-task... It's a task runner built in go.
@putnam120
@putnam120 9 місяців тому
What part of the video covers docker?
@wompaper
@wompaper 7 місяців тому
Why don't you use lowerCamelCase convention for naming methods and vars? I'm completely new to golang and that seems very odd, is there a different convention for go?
@anthonygg_
@anthonygg_ 7 місяців тому
Lowercase methods are private. Uppercase are public. I know, super awkward
@MaybeBL1TZ
@MaybeBL1TZ Рік тому
i'm new to golang and i didn't understand everything but obviously i'll watch this video 10 times to understand everything but 1 question why you don't use Neovim ?
@anthonygg_
@anthonygg_ Рік тому
Used vim for years. But VSCode customized is just so good. No hassle spending hours configuring. Syncs with all my machines. But neovim is good, its just not worth my time setting it up again. And vscode scales nice for recording also.
@rtacconi
@rtacconi Рік тому
are you using a vim plug in for vs code? Which plug in?
@anthonygg_
@anthonygg_ Рік тому
The default official one
@hakimchulan
@hakimchulan Рік тому
Any tips how to get postman to send request? At 23:30
@rahimsamai
@rahimsamai 8 місяців тому
an time i watch your videos i stop the video maybe 232343 😅😅 time to understand what are u do ,thank you
@amarwavare711
@amarwavare711 6 місяців тому
Thumbnail 😂 👌
@azizutkuozdemir
@azizutkuozdemir 7 місяців тому
The guy doesnt give the fish but teaches how to catch it
@hpn1427
@hpn1427 10 місяців тому
Yes, you are "fast" but that is not always best when you are aiming to teach others and do a tutorial on something, I agree that being fast is amazing (for many things), I am 140-145 wpm typist (you are probably even faster than this) and I am also a vim user for many years. It was really hard to follow this video, had to stop it multiple times. However, good quality video anyways
@notnull01
@notnull01 Рік тому
What logger do you use?
@anthonygg_
@anthonygg_ Рік тому
Think its logrus "github.com/sirupsen/logrus"
@notnull01
@notnull01 Рік тому
Thanks! Great video btw..
@errre8091
@errre8091 Рік тому
Very good video but the library used here is no longer mantained, be carefull!!.
@anthonygg_
@anthonygg_ Рік тому
True!
@btowers
@btowers Рік тому
Why mux and not gin for example?
@anthonygg_
@anthonygg_ Рік тому
Both are fine.
@pabloqp7929
@pabloqp7929 8 місяців тому
pretty please, needs to be zoomed in for the mobile users
@anthonygg_
@anthonygg_ 8 місяців тому
Zoom your phone or pay me money
@KendaBeatMaker
@KendaBeatMaker 7 місяців тому
in 30 min? ok let me see this
@anthonygg_
@anthonygg_ 7 місяців тому
I think this is part 1 😢
@Saulo_Al3arabi
@Saulo_Al3arabi 5 місяців тому
15:25
@eldaradylbekov3585
@eldaradylbekov3585 Рік тому
where are you from?
@anthonygg_
@anthonygg_ Рік тому
Belgium
@fannigurt
@fannigurt Рік тому
Did you find what's was wrong with content-type?
@anthonygg_
@anthonygg_ Рік тому
I think it was header.Add that was the cullprit
@fannigurt
@fannigurt Рік тому
@@anthonygg_ If you write bytes to the response, then you cannot write a header after the fact. So first setting headers then WriteHeader for status. It will work! 😌
@anthonygg_
@anthonygg_ Рік тому
@@fannigurt Dayum this is so true! Thanks for this!
@golodiassaid4879
@golodiassaid4879 Рік тому
I am still stuck at understanding your error handling methods. I think they need their own session
@aiwanmaswood9219
@aiwanmaswood9219 10 місяців тому
make run not work for me
@ciscoramonsanchez5192
@ciscoramonsanchez5192 11 місяців тому
I'm afraid of using golang web framework. My fear is that in some day they will just stop being maitained and booom! need to migrate
@jsonkody
@jsonkody 10 місяців тому
16:20 "Hey boss*, I've accidentally deleted production DB and then all backups .. it was a happy little accident" ( ͡° ͜ʖ ͡°) * Rob Boss
@paulsanchez5030
@paulsanchez5030 10 місяців тому
Yo, t'es francophone ?
@yjawhar
@yjawhar Рік тому
Please zoom in when you're coding! I can barely see the code!
@anthonygg_
@anthonygg_ Рік тому
200 dollars
@yjawhar
@yjawhar Рік тому
@@anthonygg_ Fine! Send me your Cliq and I'll wire them!
@domdirector
@domdirector 11 місяців тому
this dude sounds scottish
@anthonygg_
@anthonygg_ 11 місяців тому
Flemish
@user-ne6zt8tn8w
@user-ne6zt8tn8w 6 місяців тому
DO NOT WASTE U TIME, the video series is not complete. You can check out part 5 comments, 7 month ago this guy promised a new video in 2 weeks and never delivered. The video series stops at authorization, it doesn't get to the banking API. The code he wrote during these 5 tutorials has a lot of temporary solutions, which he promises to fix in future videos that don't exist. It's ridiculous it's called a COMPLETE JSON API, I have no idea why there is so much positive feedback here, it's a scam
@anthonygg_
@anthonygg_ 6 місяців тому
The bastard! Lets call the police.
@user-ne6zt8tn8w
@user-ne6zt8tn8w 6 місяців тому
@@anthonygg_ Yeah, yeah, very funny. Waste your viewers time and then mock them in the comments
@esirodavies8558
@esirodavies8558 Рік тому
With the mux router you can specify the method for the route 15:41 router.HandleFunc("/accounts", makeHTTPHanlerFunc(s.handleGetAccount)).Methods("GET")
@anthonygg_
@anthonygg_ Рік тому
Thanks!
@mklk7377
@mklk7377 Місяць тому
Look is American but the sound is indian
@iqbalk5731
@iqbalk5731 6 місяців тому
Hi @anthonygg_ could i ask you, what is your vscode theme?
@tendency5272
@tendency5272 6 місяців тому
GruvBox
@flalspspsl6858
@flalspspsl6858 10 місяців тому
oh great, and now mux is deprecated
@guledomer
@guledomer 11 місяців тому
gorilla mux is dead any good alternative recomendation.
@livghit
@livghit 10 місяців тому
Fiber , echo or maybe gin all three are solid
The TRUTH About Golang Backend Frameworks
6:31
Melkey
Переглядів 90 тис.
Сын Расстроился Из-за Новой Стрижки Папы 😂
00:21
Глеб Рандалайнен
Переглядів 4,5 млн
Зомби Апокалипсис  часть 1 🤯#shorts
00:29
INNA SERG
Переглядів 4,2 млн
Rust 🦀 CRUD Rest API - Rust, Postgres, Docker, Docker Compose
29:27
Francesco Ciulla
Переглядів 90 тис.
Beginners Should Think Differently When Writing Golang
11:35
Anthony GG
Переглядів 85 тис.
Ultimate Golang Developer Roadmap 2024 🚀
11:46
practicego
Переглядів 16 тис.
This Is The BEST Way To Structure Your GO Projects
11:08
Melkey
Переглядів 54 тис.
When RESTful architecture isn't enough...
21:02
Dreams of Code
Переглядів 236 тис.
Build ENTIRE Frontends With ONE Prompt - OpenUI Tutorial
8:59
Matthew Berman
Переглядів 27 тис.
They Enabled Postgres Partitioning and their Backend fell apart
31:52
Hussein Nasser
Переглядів 36 тис.
Big Tech AI Is A Lie
16:56
Tina Huang
Переглядів 56 тис.
Сын Расстроился Из-за Новой Стрижки Папы 😂
00:21
Глеб Рандалайнен
Переглядів 4,5 млн