Go Fiber

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys lenĂ´tre has managed kubernetes and they're keeping their usual simple pricing model there's no management fees like AWS and other cloud providers they even bundle transfer so you can significantly cut cost when compared to AWS Google cloud platform and Azure with the amount you save if you're doing any K eights it really doesn't make sense to use anybody else but one node it's now even easier to connect to your low node account with one less login to remember you can use your github account give it a shot the link is in the description tab of this video below and if you use that link you'll get a $20 credit hey guys what's up alright so in this video what we're gonna be talking about is the new fiber framework from the go community and I know you guys are thinking another effing language another effing library why do I want to do that but let me go ahead and get into it because I think this one's a little bit different it actually has me more excited than other projects that I've seen especially when it comes to web and being a web framework I feel like things have gotten a little bit stale and predictable and that's because I really feel like so many people have moved over to no js' that way we kind of use nodejs for everything people that know Django and Ruby on Rails and stuff they probably still use that stuff but seems like everybody else has kind of moved over to node and it just seems kind of stale right like we're always doing stuff in Express there's a couple of other frameworks that I'm impressed with with node like fast to find all that stuff but basically nothing wrong with Express it's done the internet quite quite well a lot of people use it but I think it's stale and boring this is the number one selling point of why you would want to use fiber for your next project when you look at the actual responses that fiber is able to do overexpress it's actually mind boggling so I'll have this benchmark link in the description tab below if you guys want to check that out but it's it's mind-boggling the amount of time that you'll save on latency and just the amount of you know the amount of responses and requests and responses that this thing can handle versus a simple nodejs Express fast web server so if we just move down through the list here I mean even Jason Jason serialization I mean that's like five times this of express so when I started when I saw this I was like wow you know this is this is gonna be something pretty interesting it does it actually work you know can you actually build a website in it and to answer that question yes you can it's already on a stable 1.0 version it's actually on 1.1 two right now and there I've noticed a couple of bugs with it there's one that's actually going on right now with a Windows machine where like there's a caching problem on the server but it's a brand-new project so keep that in mind it has a healthy amount of contributors for such a small project and it's only been around for six months so how hard is it to get started it's actually not that difficult you just have to have go installed on your machine once you have go installed and set up so that you can actually execute go programs then it's simply just firing one single git command and you can get up and running with the project so to save you guys a bunch of time I actually created just a quick like a quick start on github so if you guys want to check that out as well the link is in the description table below but it essentially just comprises some of the basic stuff do you need in order to get started with quickly which is like how do I deliver JSON data how do I deliver HTML how do i render static content basically all the stuff that a typical website needs so that said if I just jump right into the code it's actually very basic to get a web server running I have a web server running right here and just say if I'll go through the code real quick you have your imports right this is the import for the fiber library that's really all that's needed in your go code this is because I'm going to be serializing some JSON data so that's what that's for you define an interface so it said well here's a struct specifically but so my JSON data will have like a page and which is an integer and then an array of fruit values that gets returned so the main function of a go app is obviously the starting point this is where the app gets nude up so you just create a new instance of fiber and then from there you just simply do your routing like we've we've seen so a lot of these statements are very repetitive essentially but you're just defining your routes and then defining the response so I have a bunch of different routes already pre-configured so if I go to localhost since this is already running and if I go all the way down to the bottom of the code here you can see it's actually listening on port 3,000 very similar to no js' right so if I go to the home page you get hello fiber let me make this smaller alright so you get hello fiber there at the root directory this is where the static content is being rendered so here you can go ahead and define a folder where your static content sits so that's what I went ahead and did I just created a public folder and then I also this is the actual URL that says if you request the public and the URL point to the public folder and then you know deliver that so right now I just have the simple CSS folder image folder and a JSON I'm sorry javascript file and then here is a templates folder which is the actual template that's being returned if we request it here so that is what's going on here so if I go to app get hello route it's going to read the template file and then return it and if we look inside the template you can see all the static content of the template is referencing that public directory and the built in static file handler within within this project is is returning the content and then from there all you have to do is if you have a working go installation you just say go run start go or whatever the name of your file is in this case it's start dot go and the application is running so let's go to the hello page and this is where that bug I was telling you about for some reason there's a caching problem it actually just got reported so that working on that but if i refresh it comes back so that's a problem zoomed in really high right now that's the the normal zoom so this is a HTML templates already being that's being returned here by the server and then just it's referencing obviously the the image here there's a CSS file that's being loaded as well as a javascript file the JavaScript file has one method so if you fire this button click it's going to call out to the API and it's going to get a JSON response so it's alerting that to the page so that's a bench event essentially like what you need in order to get started with this project quickly so if you guys want a reference that just check this out I have all the examples of like navigating to the individual pages here including like how to get parameters wild cards so that you can actually design your own API and an example of that if I were to change this route to API I can go to the fruits page that is returning that content or that you know it's the response from that JSON call that we had but I can also with that wild card I can also do things like users Chris and then this is actually saying it's capturing the parameter so you can do lookups with this so the way that the fruit is being returned is just a simple if condition just as an example and it's really sloppy just it's just simply to get you started real quick but this right here is the wild card so I'm actually printing out the values that you can do something with so I say do something with these lookup values that means like read from a local file or call out to a database or do something with whatever that parameter is and return with some data here I just did that like I said the if condition to say if you request the fruits and then this is where I'm actually just creating some I'm doing some JSON serializing and such so anyway that is that is the fiber project in a nutshell I think it has pretty much everything you need for basic websites and the speed factor alone is one is really the number one selling point the fact that this thing just seems to work obviously some minor bugs for a project is only six months old I think it's a pretty impressive what's going on so you guys should definitely check it out and for those of you that are not aware make sure you guys check out my site if you're learning to code and you guys want to learn to code with me I have courses on all kinds of different stuff I'm trying to add to that as I can and then there's just other content on the website so I'm trying to fill out the website more and more over the weeks months years I suppose it's a long term project but anyway guys thanks for watching have a good day bye
Info
Channel: Chris Hawkes
Views: 54,997
Rating: undefined out of 5
Keywords: chris hawkes, Why Go Fiber Is THE New Framework To Learn, golang, go, go fiber, fiber tutorial, fiber web framework, fiber example, fiber tutorial for beginners, learn fiber, learn golang, fiber crash course, fiber course, golang crash course, go programming language, golang tutorial, go programming, go programming tutorial, go tutorial, golang tutorials, go rest api, fiber, microservice, microservices, golang tutorial for beginners, golang rest api, fiber go
Id: kvwsPeWDLM8
Channel Id: undefined
Length: 9min 6sec (546 seconds)
Published: Mon Jun 29 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.