Go API Tutorial - Make An API With Go

Do you like programming in Go? If you do then this video is great for you! In this tutorial video I share with you how to make an API in Go! More specifically we are going to be using Gin which is a high performance and relatively simple web framework that will allow us to quickly design and make an API in Go. Hope you enjoy!
💻Thanks to ServerPronto for sponsoring this video! Build your custom data center today and pay ZERO up front. Take advantage of a 10% discount by using code: CREATOR21 www.serverpronto.com/?src=cctim
💻 ProgrammingExpert is the best platform to learn how to code and become a software engineer as fast as possible! Check it out here: programmingexpert.io/tim and use code "tim" for a discount!
📄 Resources 📄
Code In This Video: github.com/techwithtim/Go-API...
Gin Framework Docs: github.com/gin-gonic/gin
Go For Beginners Tutorial Series: • Golang Tutorial #1 - A...
⭐️ Timestamps ⭐️
00:00 | Overview & Prerequisites
01:07 | ServerPronto
02:08 | Dependency Setup
04:47 | Imports & Data Setup
09:22 | Gin Router Setup
09:50 | GET Requests
14:22 | POST Requests
21:51 | Fetching By ID
29:01 | Checkout Books & Query Parameters
33:04 | PATCH Requests
34:30 | Returning Books
37:12 | Conclusion
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
👕 Merchandise: teespring.com/stores/tech-wit...
📸 Instagram: / tech_with_tim
📱 Twitter: / techwithtimm
⭐ Discord: / discord
📝 LinkedIn: / tim-ruscica-82631b179
🌎 Website: techwithtim.net
📂 GitHub: github.com/techwithtim
🔊 Podcast: anchor.fm/tech-with-tim
🎬 My KZread Gear: www.techwithtim.net/gear/
💵 One-Time Donations: www.paypal.com/donate?hosted_...
💰 Patreon: / techwithtim
◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️◼️
⭐️ Tags ⭐️
-Tech With Tim
-Go API Tutorial
-Make An API With Go
-Programming With Go
-Golang
⭐️ Hashtags ⭐️
#TechWithTim #GoAPI #Golang

Пікірлер: 109

  • @mechwarrior83
    @mechwarrior83 Жыл бұрын

    I love the fact that you leave your mistakes in. It shows us that even super human programmers make mistakes, gives me a chance to pause and take a stab at the issue, and finally you break down your thought process behind the troubleshooting.

  • @Moccar
    @Moccar2 жыл бұрын

    Great tutorial, Tim (as always!). It's good to see some tutorials that are not just going over basic syntax. This is still very simple but it illustrate a real world example!

  • @hmshuvo2332
    @hmshuvo23322 жыл бұрын

    Perfect place to go for GO for the first time!

  • @JohnBoen
    @JohnBoen2 жыл бұрын

    Excellent demonstration of some key features. I've never played with GO before - I never thought about it as anything more than a wrapper language for deployments and such... Thanks for opening my eyes. I think I will be trying my hand at a Go web page this weekend.

  • @horizonariondust576
    @horizonariondust5765 ай бұрын

    Been looking for a simple yet clear and concise tutorial to learn Go then found your channel, It's perfect! My homework now is to read about pointer, what does it do and why do we need it on Go? I'm using C# and I'm a bit confuse for what is that for Thanks a lot, Tim!

  • @myschored
    @myschored Жыл бұрын

    Short and simple tutorial. Great works Tim!

  • @timothyn4699
    @timothyn46993 ай бұрын

    got more out of the video then expected, helps clarify a lot of the little details and what gin is doing. Thanks!

  • @grantwells16
    @grantwells162 жыл бұрын

    GO is so sick. Would love to see an advanced tutorial

  • @LassePhlipsson
    @LassePhlipsson Жыл бұрын

    Thanks for this tutorial. That is a really great start to get the basics and continue from here!

  • @youngscientistacademy7689
    @youngscientistacademy76892 жыл бұрын

    Another seriously great tutorial...... thanks Tim

  • @lucasfe3436
    @lucasfe34368 ай бұрын

    I could learn many things, thanks Tim. I hope that you launch new videos about GO which is a great programming language

  • @gogopher1093
    @gogopher10932 жыл бұрын

    I'd love to see more Go tutorials! Concurrency, databases, etc.

  • @jamesmwangi2491
    @jamesmwangi24912 жыл бұрын

    simple and straight foward.

  • @chrisjarvis509
    @chrisjarvis509Ай бұрын

    Great video! Mistakes are the best ways to learn... glad you kept them in

  • @bavan1358
    @bavan13582 жыл бұрын

    thank you so much,i was actually searching for this.please make more videos of golang

  • @luciaravazzi6925
    @luciaravazzi69252 жыл бұрын

    Reaaaally cool! Thanks ✌ Guys, pay attention to the terminal: he is using CMD to execute the curl commands! It doesn't work out using the power shell

  • @cigetbudi

    @cigetbudi

    2 жыл бұрын

    yeah i have tried it first lol

  • @jacksonwachira6706

    @jacksonwachira6706

    2 жыл бұрын

    You saved a life here. I was pretty frustrated.

  • @manishkrsingh7684

    @manishkrsingh7684

    Жыл бұрын

    Thanks for this comment.... it really saved me

  • @MrCleverOnion

    @MrCleverOnion

    4 ай бұрын

    No sh*t genius. Thanks for stating the obvious

  • @hamood932

    @hamood932

    Ай бұрын

    @@MrCleverOnion found the biden supporter

  • @abdullahraihanbhuiyan2346
    @abdullahraihanbhuiyan23462 жыл бұрын

    Nice introduction! Thanks!

  • @gshan994
    @gshan9942 жыл бұрын

    Go is best suited for backend infra...and recently AWS released aws cdk support for GO.

  • @johnxisde
    @johnxisde Жыл бұрын

    Thanks for that, Tim!

  • @umeshnikam8043
    @umeshnikam80432 жыл бұрын

    Excellent demonstration

  • @ch0wderz912
    @ch0wderz9122 жыл бұрын

    I wished I didn't pick this language but it's so cool and really powerful. When you understand the concepts it's pretty easy to pick up! Thanks for teaching sir!

  • @efehanturhan6763

    @efehanturhan6763

    2 жыл бұрын

    why did you say that bro, i were planning to learn and master go

  • @ch0wderz912

    @ch0wderz912

    2 жыл бұрын

    @@efehanturhan6763 it depends on what you wanna do with the language, Go is good for blockchain and networking. I didn’t think it was fun so I decided to learn C# for gaming. Idk I’m just lost right now due to the fact what job role I want.

  • @chem826
    @chem8262 жыл бұрын

    Need more golang tutorials, thank you sir!

  • @shaneoh
    @shaneoh Жыл бұрын

    Many thanks Tim.

  • @Tiqqle
    @Tiqqle Жыл бұрын

    Thank you for this tutorial

  • @thisiscrispin
    @thisiscrispin Жыл бұрын

    Amazing, thanks!

  • @prakarangsa-ngamatong193
    @prakarangsa-ngamatong19310 ай бұрын

    thanks for the tutorial!

  • @utkarshpandey491
    @utkarshpandey4912 жыл бұрын

    Thanks sir very much!! 😇

  • @nitin_puranik
    @nitin_puranik6 ай бұрын

    Loved this tutorial, very helpful! Thanks, Tim. The only thing I didn't quite follow was why you used router.PATCH at 33:05 - didn't quite get the rationale behind when to use PATCH versus POST.

  • @madhavan_vj

    @madhavan_vj

    5 ай бұрын

    Post is not idempotent i.e will create duplicate resources instead of updating the existing one.

  • @pedromiguel-fs7ux
    @pedromiguel-fs7ux Жыл бұрын

    great video, thanks

  • @acronproject
    @acronproject11 ай бұрын

    Thanks for this

  • @TheChemicalWorkshop
    @TheChemicalWorkshop2 жыл бұрын

    already got one with quart... but not bad !

  • @dipsagungurung4553
    @dipsagungurung45532 жыл бұрын

    love GO

  • @manishkrsingh7684
    @manishkrsingh7684 Жыл бұрын

    Great awesome explanation

  • @mehdismaeili3743
    @mehdismaeili37432 ай бұрын

    Excellent .

  • @utkangul5674
    @utkangul5674 Жыл бұрын

    great job!

  • @jonathanlambrecht5642
    @jonathanlambrecht56428 ай бұрын

    im just starting, few weeks watching some videos, mainly for deciding my route learning go (not falling for tut hell again as i did learning arduino/pic and it took a lot of time), and what i get from this video is that this is very simple, but i do not undestand what and why the framework is doing whatever it is doing (because i do no get it lol) so i think i need to learn without any framework, the same goes with gorm, yeah pretty straight forward, but i think im going to study postgres too, maybe im wrong or dumb for not getting how this works, idk...any thoughts?

  • @beaumontyun3872
    @beaumontyun38722 жыл бұрын

    Surprisingly I could not use curl to do a PATCH request, whereas it's possible for any other request. It was only available when I used Postman or Insomnia to do the PATCH request, so strange...

  • @professor1429
    @professor14296 ай бұрын

    Thanks!

  • @TechWithTim

    @TechWithTim

    6 ай бұрын

    Thank you!

  • @mytralala6474
    @mytralala6474 Жыл бұрын

    Hello, which Go extension do you use? My json tags are not showing up.

  • @danangjehan9733
    @danangjehan9733 Жыл бұрын

    so why do we need to type "example/" in command go mod init and what exactly "example" is ? 😃

  • @pranavsharma7479
    @pranavsharma747911 ай бұрын

    There is no need to use json tags in the book struct as the IndentedJSON fucntion encodes the go structs into json itself.

  • @ishan_sinha
    @ishan_sinha Жыл бұрын

    If I am not using gin, how else can I bind the json to the object?

  • @NATAR160
    @NATAR1602 жыл бұрын

    Gin not good for large scale application? Which do u recommend?

  • @ccindy951357
    @ccindy9513573 ай бұрын

    謝謝!

  • @ezrablack5395
    @ezrablack53956 ай бұрын

    Great video Tim! For anyone else running on MAC, if you get the error zsh: no matches found: localhost:8080/checkout?id=3 then run the curl command like this - curl -s -X PATCH 'localhost:8080/checkout?id=3'

  • @yevgeniypak1220
    @yevgeniypak12206 ай бұрын

    Can someone tell what Go extension for vscode is used in this tutorial? I am using just "Go" extension, but I really hate the way it formats the code on save action and also it replaces spaces for tabes. And the problem is that I can't find the point in extension settings where I can fix these behaviours...

  • @michelchaghoury870
    @michelchaghoury8702 жыл бұрын

    great vid, google uses golang, but wich framework do they use? do they use gin?

  • @AbhishekBM

    @AbhishekBM

    2 жыл бұрын

    Knowing Google, they probably use their own framework

  • @kabir0x23
    @kabir0x239 ай бұрын

    amazing

  • @jotunros
    @jotunros5 ай бұрын

    Why is there a books.Quantity

  • @luciaravazzi6925
    @luciaravazzi69252 жыл бұрын

    I'm waiting for assembly tutorial 🤟🤟🤣

  • @raoulkent

    @raoulkent

    2 жыл бұрын

    Whoah there, calm down Satan

  • @riordan381
    @riordan381 Жыл бұрын

    I dont know what settings to change but on go extension file, when I save a file, it automatically removed all the unused imports. I dont know where to turn this off on VSCode

  • @ScottKFraley
    @ScottKFraley Жыл бұрын

    Really curious about why you made the struct'd Id field a string vs. an int or other 'actual' numeric value? :)

  • @rssaiganesh

    @rssaiganesh

    Жыл бұрын

    Late reply, not sure if you already have found the answer, but i believe it's because the id is being used in the GET method of bookById. Can anyone let me know if i am correct in this?

  • @YnjeviYhhei

    @YnjeviYhhei

    Жыл бұрын

    in a real DB it would be an uuid which is a string

  • @Chips4Real1

    @Chips4Real1

    Жыл бұрын

    why would u need it to be a number, youre not gonna be adding or subtracting ids from each other

  • @ScottKFraley

    @ScottKFraley

    Жыл бұрын

    @@YnjeviYhhei Not necessarily, but I get your point.

  • @ScottKFraley

    @ScottKFraley

    Жыл бұрын

    @@Chips4Real1 Takes way less space that way, no? I've NEVER used a string as an ID unless it was in fact a GUID/UUID. I mean, I definitely would NOT store a phone number as an actual number because no reason. But I have had plenty of tables that used either an int, or a bigint (long in C#) and again, it's my understanding that numbers take way less space than a string does. (Depending on the length of course. But a short string won't be a good Id for a table unless it's a really small / lookup table or some such.)

  • @siyaram4237
    @siyaram4237 Жыл бұрын

    Great tutorial but, I was expecting you to test the API endpoints on applications like Postman. Apart from that I was hoping you would saperate things in folders like, Struct folders, Controller folders and Repository folders.

  • @MusiQ8dict

    @MusiQ8dict

    9 ай бұрын

    Any pointers for videos regarding ehat u asked ? Am a newbie

  • @hachikoi-san3901
    @hachikoi-san3901 Жыл бұрын

    20:38 Yep you need o specify that is a POST req

  • @bhavyavijay0
    @bhavyavijay03 ай бұрын

    I did not get the Fetch by id part like how did that error got fixed and why it was not sending the error message

  • @huntercoleman1347
    @huntercoleman13475 ай бұрын

    If anyone is having issues with the PATCH command not working, your curl may be aliased to Invoke-Webrequest. In the terminal, run Remove-item alias:curl and then run the patch command again to checkout a book. I was getting frustrated trying to figure this out, so hope this helps if anyone else is having the same issue.

  • @brahmkaransingh8804
    @brahmkaransingh8804 Жыл бұрын

    Can anybody tell is gin framework a third party package or not ?

  • @xineric1734
    @xineric17342 жыл бұрын

    great tutorial, but it's easy for me

  • @chuibete
    @chuibete Жыл бұрын

    Not bad but in the dev process it has documentation and tests ... where are they ... it is important and it miss

  • @shubhampokhriyal8491
    @shubhampokhriyal84912 жыл бұрын

    Any good course for golang backend??

  • @webfactorysolutions

    @webfactorysolutions

    2 жыл бұрын

    what do you mean? this is backend

  • @shubhampokhriyal8491

    @shubhampokhriyal8491

    2 жыл бұрын

    @@webfactorysolutions no I mean more content like udemy course like that

  • @user-zx3vp8mw7d
    @user-zx3vp8mw7d2 жыл бұрын

    Nice tutorial but won't these frameworks weaken our programming skills?

  • @esper4605

    @esper4605

    2 жыл бұрын

    That's a question that I've mulled over for a long time! I feel like the more we become dependent on high level abstract tools, the less we need to know of the actual "rules" of writing software that performs specific tasks. At the end of the day, we're telling someone's tools that they wrote to tell someone's tools that they wrote to tell someone's tools (etc etc). I feel like we're hitting a point of fragility. It's VERY important to understand how to use lower level languages in case everything needs to be torn apart and redone from scratch. It's ALWAYS important. This is the "zombie apocalypse" of software development, but it is a true fear I have had for a long while.

  • @johngodoy2929

    @johngodoy2929

    Жыл бұрын

    @@esper4605 Isn't the goal to just get the problems solved?

  • @JohnnyBigodes
    @JohnnyBigodes5 ай бұрын

    Has everything to be on a single file? Every tutorial I see everything is always on the same file. I want to structure my code, over multple files so, that go doesnt look like spaghetti code.

  • @jotunros

    @jotunros

    5 ай бұрын

    Unfortunately most of his tutorials are like that. I treat it as nothing more than prototyping just so you can quickly "dip your toes in the water" so to speak. You need to actually look for some other resources on design. Most commercial applications will have tons of more work to be done when implementing a single rest service/microservice. I come from Java so a good point of reference is how the Spring Boot Api services are structured.

  • @techwithzaitri9458
    @techwithzaitri94582 жыл бұрын

    yes

  • @tegacreatives1673
    @tegacreatives1673 Жыл бұрын

    The splatting operator '@' cannot be used to | reference variables in an expression. '@body' | can be used only as an argument to a command. What does this error mean?

  • @yellowman4173

    @yellowman4173

    Жыл бұрын

    I have the same problem. Did you find a solution for this?

  • @erikolkonen2915

    @erikolkonen2915

    Жыл бұрын

    Same issue for me. Tried using curl.exe instead but no luck yet.

  • @maxwl76

    @maxwl76

    9 ай бұрын

    I swapped to cmd instead of powershell and it works for me

  • @maxwl76

    @maxwl76

    9 ай бұрын

    @@yellowman4173 I swapped to cmd instead of powershell and it works for me

  • @maxwl76

    @maxwl76

    9 ай бұрын

    @@erikolkonen2915 I swapped to cmd instead of powershell and it works for me

  • @Nellak2011
    @Nellak20112 жыл бұрын

    I wish this made sense to me. It is very convoluted.

  • @arab01001
    @arab010017 ай бұрын

    10:55

  • @joinadduk
    @joinadduk2 жыл бұрын

    1st

  • @aliguliyev2122
    @aliguliyev21222 жыл бұрын

    First

  • @FPChris
    @FPChris2 жыл бұрын

    Ug. Sponsor:(

  • @helloworld7796
    @helloworld77962 жыл бұрын

    Why almost every tutorial is with gin or some other framework. Why there is no simple go tutorial, without any extra frameworks etc.

  • @lemmyz1
    @lemmyz1 Жыл бұрын

    Ahhh this paid promotion thing is so annoying.. it hides content as I'm watching from TV..

  • @iamworstgamer
    @iamworstgamer3 күн бұрын

    this is most useless tutorial i have ever seen.

  • @user-kw9cu
    @user-kw9cu Жыл бұрын

    why are teaching stuff that you dont even know

  • @jessicadowning3170

    @jessicadowning3170

    Жыл бұрын

    It was really helpful for me to see him make mistakes and then go back and explain why he made a mistake. I learned a lot from his video and I'm sure he did too. One of the best ways to solidify something you've learned is to teach it to someone else. If no one ever taught things they hadn't already mastered, there would be a lot less knowledge shared. Don't discourage people from sharing just because you're grumpy.

  • @opcon3155
    @opcon31552 жыл бұрын

    Great video but Java and Python will always rule over the others

  • @paschalokafor9043
    @paschalokafor904311 ай бұрын

    @27.58, you could also use c.AbortWithStatudJson. Meanwhile thanks for this video. I learnt alot.