Build a REST API in Go using Fiber + GORM
Vložit
- čas přidán 20. 06. 2024
- In this video we're going to build a REST API in Go using the web framework Fiber and the Go ORM library GORM alongside a SQL database
👨💻 Looking for a web developer job, visit: www.webdevjobs.io/
👽 Discord - / discord
⏳ Timestamps
00:00:00 - Project Setup
00:09:00 - Database
00:13:00 - Creating our models
00:22:14 - User routes
00:51:12 - Product routes
01:06:53 - Order routes
The finished code can be found here:
👾 - github.com/sixfwa/fiber-gorm
#Go #Fiber
👽 Join the Discord Server (link in the description)
this video is gold, i needed to learn go for a project within a week and this covered largest chunk of it in under 2 hours
Im glad this helped :)
The fact that you're repeating the crud functionality with different parts of this project is so awesome because after the second or third time people can see the pattern and have a higher chance of not just memorizing but learning how to implant a CRUD operation into a service, and don't let me start on how great the explanations were. great job with the tut and please do keep up with the good work!
Thank you so much for this comment. I’m really glad that this tutorial came across that way. This comment has made my day!
More to come
Coming from a Laravel and node background, this was just so simple to understand and follow. Thank you.
Thanks for the comment! So glad this helped
You are saving lives, this is an amazing follow along tutorial
Glad it was helpful & thank you for the comment!
nice content, keep it up!
Thank you !!!
Have been using Django and Flask since I got into backend development and you made it pretty simple and easy to understand. Thank you soo much.
Im really glad that this is the case, thank you!
Amazing tutorial! Thanks a lot.
Thanks for the awesome comment! Glad it was helpful
Thank you, very useful tutorial, I've learned a lot as I needed this since my company wants me to start doing backend with GO. I created all this code along with you with my own modifications. Great stuff.
Fantastic and best of luck!!
Great learning experience with this channel. Thank you and please create more videos.
More on the way!!
I came from Laravel and Rails. and I just learn Go and I found your tutorial. Its very helpfull for beginner like me.
This is very simple example. Thanks
Really glad that this was helpful
thanks, now i understand the basics how fiber and gorm works 😁
That's great to hear :)
thank you very much friend, very good explanation :)
Thank you for the great comment!
Awesome. Now I got the big picture of API as a full
Thanks for the comment! I’m glad this was useful
nice tutorial! great presentation 🙂 you should do more GO tutorials
Thank you! Yes I have more planned :)
Nice tutorial and ecpected more on user login authentication(JWT) like so..❤
thanks a lot for this video, for my that i am beginner is very import and a lot util this clase of video
again thanks!
You are more than welcome
Great Video.
Glad you enjoyed it
Thank you so much for sharing. I liked your Golang crash course, the repository was cozy because the commits matched with the timestamps. Can you upload this repo in the same way?
thanks for the awesome comment :). Yes i will look into re uploading the code so it's more inline with each section. Thanks for the hint, will also keep this in mind for future content
very usefull👍
Glad you think so!
thank you
You're welcome 😊. Glad you enjoyed
Great
Thank you
You are more than welcome!
Nice tutorial, how do you align your code vertically ?
This is great.
Btw vs code theme ?
Nice video, clear explaination. I think we should call that controllers instead of routes.
Yes that is also a very valid name!
спасибо = )
what do you use to auto indent the data types of your model fields
Great content. Could you plz add pagination function~
Please add more videos on golang with gin framework
Thank you very much. Your content was helpful. Better if you could use proper HTTP response codes as well.
Why do you use sometimes "int" and sometimes "uint"?
Isn't that (id) the same field and should also use the same data type?
Btw. good video!
"int" accepts both negative and positive numbers where "uint" accepts only positive numbers.
The video duration is more than one hour, but I took more than one day to learn and finish your video. Thank you for sharing, and keep it up!
Im glad it was of use to you :). Thank you for the comment
what if I want to order multiple products at one go ?
may i ask about the name of your vsc theme?
Noctis Theme
Great video!
VS Code Theme bro, pls :)
Ok. Maybe I got it) This is Noctis Sereno with chaned background
Yes exactly
Hey, I am working on updateOrder function I have an issue in update User value for
example
var user model.User
database.DB.Find(&user, "id=?", order.UserRefer)
order.User = user(I am getting a issue here) like json: cannot unmarshal number into Go struct field
Hey sorry this is fixed
I am tring to update order like this
order.User = user
order.Product = product
database.DB.Save(&order)
Its not working let me know any input from you
@@LearnProgramsCJ nice one 🔥
Are you from germany?
I'm not from there, but i do live in Germany :)
@@iamrithmic oh nice! Could you do React Typescript Authentication with a database? Its really asked and nobody has a good video about it
Every time you mention "gorm", I think of "blue", as in Irish "gorm" [said a gur-um] means "blue". Also, speaking of blue in Irish, "fear/bean gorm" [far/ban gur-um] literally translates to "blue man/woman", but it means a black man/woman, as to call a person "black" or "dubh" [dove] means they are bad/evil.
how about testing API?
Good idea, will think on that one
Theme name please?
Noctis collection
please what is your thème name?
Noctis Theme
Authentication please
37:44 memo 22.9.13
I gave up after 21 minutes. Only because some of the commands are for Linux (e.g. "APP_ENV=dev"). I desperately tried to get it to work in Windows, but it is slow to run (I think it's gcc)
Great Video, but be careful DO NOT this in production. This called an N+1 query, where for each order, he's searching the product and the user db for the user and the product. This is not a very good practice. Instead try to use something like eager loading or table joins. But for an educational purpose, good material.
This is an important point. Yes in the context of this video it had to be overlooked. But in a professional setting, you're 100% correct
Hi, congrat about the content.
I try to follow your tutorial, but i have a problem in app.Post("/api/users", routes.CreateUser)
Message is:
cannot use routes.CreateUser (value of type func(c *fiber.Ctx) error) as func(*fiber.Ctx) error value in argument to app.PostcompilerIncompatibleAssign
I tried in my windows 10, and i thought that was some incompatible with windows, I tried in my ubuntu and had the same problem.
I searched in web, but nothing else help me.
How solve it?
the code is exactly the same as yours.
My go version is 1.17.5.
Thanks
Toti
Awesome tutorial, it easy to follow the step,
by the way, what theme of vs code did you use? @rithmic
with air i get : "Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub"
and with run main.go it says :" C compiler i.e. gcc is not in path
After countless tries i could not fix it, so i decided to use a different cgo free driver, which is although a bit slower but gets the job done