Transcript for:
Introduction to Go Language Basics

hey there gang and welcome to your very first go tutorial [Music] all right then so first of all what is go also known as golang well according to the go website go is a fast statically typed compiled language but what does that all mean well first of all compiled means that go is compiled down into machine level code that computers understand so it doesn't need to be interpreted one line at a time and that's one of the reasons it's so fast compared to interpreted languages like python now statically typed means that our variable types are checked before and time by the compiler so type errors are picked up earlier it's also a strongly typed language meaning our variable types cannot change after they've been declared so if you were to make a variable a string it must always be a string in the future it can't change into a number or a boolean or any other data type now go is also a general purpose language meaning that it can be used for many different things from building web apps and rest apis to cloud services so there's a bit of something for every developer it's also got built-in testing support into its standard library so there's no need to add any extra dependencies to write your test which is a nice bonus and finally go is an object-oriented language but not as you might know we don't use classes or constructors in go to create objects however it does use features like custom types structs and interfaces that mirror that kind of functionality so it is an object-oriented language just not in the same way as a lot of other programming languages now before you start this course i do assume that you already know the foundations of any other programming language whether that's javascript python or something else entirely and i only assume that you know the absolute basics if you understand what variables functions arrays and loops are then you're probably in a good position to learn go if not then definitely check out my javascript for beginners tutorial first of all to learn the basics of programming in general the link to that is going to be down below the video so in this series we're going to be building a fun little command line program which can be used to create and save bills for a cafe or a restaurant or something like that so we're going to be able to interact with the command line to create a new bill and we can give that bill a name we could then add multiple items to that bill and then if we wanted to we could add a tip to the bill as well and then finally we can save the bill which is gonna generate a text file for us with that bill correctly formatted including the total at the bottom and by creating this program you're going to learn most of the building blocks of the go language like how to use slices maps structs receiver functions pointers and all that jazz all right then so first things first you need to install go on your computer pretty simple to do head to golang.org the link to this is down below then click on download go and you want to choose which version to download depending on your operating system once you've downloaded it run the installer now it should automatically add go to your path environment variable on your computer but if there's an option to add it just make sure that option is checked anyway once it's installed you want to open up a terminal to check the installation and to do that all we need to do is type go and hit enter if it gives us all of these different options back then we know that go has successfully installed if not there's been some problem with the installation and you will need to re-install it but now we have go installed we can go ahead and start using it on our computer the first thing i'm going to do is open up a folder just an empty folder in vs code this is where we're going to do all of our work all right then so there is a package that you should install first of all for go support in vs code and that package is just called go so type go right here and it's this one so click on install first of all that should install pretty quickly once it's installed go ahead over here and just create a new file and i'm going to call this test dot go so it has a dot go extension and press enter now when you do that you're probably going to see these pop-ups right here so what i'm going to do where it says gopls i'm going to install all of these right here and i'm also going to click on this one install all so make sure you do that as well to get the full support inside vs code for go files and then once that's done vs code is ready and set up to work with go files now before we quit this video i just want to show you how to access all of the course files so the right over here on my github repo called golang tutorials the link to this is going to be down below the video and every lesson has its own branch in this repo because every lesson has its own code so if you want to see the code for lesson 10 for example you'd go to the branch drop down go to lesson 10 to select that lesson and you're gonna see the main.go file right here all of the code is inside that if you want to download it you can go to this code button and then download a zip file which is going to include this file and any other files that might be included in different lessons so now all of that intro and setup is out of the way let's start writing go code now if you want to watch this whole course without youtube adverts you can do i've uploaded it to the net ninja website which you can find at netninja.dev so you can buy this course for two dollars or you can access all of my courses including premium courses not found on youtube for nine dollars a month by signing up to net ninja pro and the first month is half price when you use this promo code right here anyway i'll leave this link down below in case you want to buy it now otherwise guys don't forget to share subscribe and like and i'm going to see you in the very next tutorial