Press "Enter" to skip to content

Introduction – Go Lang Practical Programming Tutorial p.1


00:00:01what’s going on everybody and welcome to

00:00:03a go programming tutorial series this

00:00:05tutorial series is going to be practical

00:00:08and applied but also over the basics of

00:00:10go the reason why I want to do it that

00:00:13way is because the go programming

00:00:15language I mean all programming

00:00:16languages are like this but the go

00:00:18programming language because it’s kind

00:00:20of a low-level programming language it’s

00:00:22kind of the case that you could go

00:00:24through a basics tutorial for something

00:00:27like go and feel like you kind of

00:00:29understood what was going on and then

00:00:31you actually go to try to apply it to a

00:00:32project or something and you’re like I

00:00:35have no idea how to do this right so so

00:00:38my hope is that each time we learn

00:00:41something we’re going to apply it to an

00:00:42overarching objective and project and my

00:00:45hope is that that’ll that’ll make

00:00:47learning go much much simpler but still

00:00:50even at the end of that the best way to

00:00:51learn something is to keep trying to use

00:00:53it to solve various types of tasks so

00:00:55some of that’s actually still going to

00:00:57be on you but hopefully I can make some

00:00:59of that initial process easier so first

00:01:02of all why go why would someone like me

00:01:04be interested and go why might you be

00:01:06interested and go basically go is built

00:01:10from the ground up it was built by

00:01:11Google it was built to solve Google

00:01:13types of problems right so basically go

00:01:16is for scale this would be like a

00:01:19systems language web development

00:01:21language anything you want to scale

00:01:22anything you want to be super efficient

00:01:25but you might not want to write in C++

00:01:26so for example the reason I’m interested

00:01:30in go is mainly for web development so a

00:01:32website like Python programming net for

00:01:34example it’s built in Python using flask

00:01:37and it’s not the slowest website in the

00:01:40world but it’s also not the fastest

00:01:42website in the world it could we could

00:01:43make some serious speed gains there and

00:01:45in web development the difference of 100

00:01:48mil or 100 milliseconds is a major

00:01:50difference especially when you scale

00:01:51that out to millions of users so it you

00:01:54know the speed doesn’t just affect user

00:01:57the user experience but it also affects

00:02:00your bottom line how much are you paying

00:02:02for processing cost basically right in

00:02:04hosting time and all of that so anywhere

00:02:07you can make gains in web development

00:02:09it’s usually a very good thing and then

00:02:10the bigger the scale the better those

00:02:12are for you also in terms of just

00:02:15anything where you need it to be super

00:02:16fast or super efficient go is pretty

00:02:18much C++ speeds so anywhere well that’s

00:02:22a good thing to you maybe you’re in

00:02:23high-frequency trading or something like

00:02:25that where you you really want to be as

00:02:26quick as possible but maybe you don’t

00:02:29want to write something as tedious as C

00:02:30so go is gonna be static typed like C++

00:02:35unlike Python so every time like in

00:02:38Python every time the interpreter hits a

00:02:40variable has to kind of figure out what

00:02:42is that variable and that variable could

00:02:43change types and stuff like that and by

00:02:45that I mean like int sand floats and

00:02:47strings stuff like that

00:02:48whereas in go that’s not the case so it

00:02:51doesn’t need to know all there it

00:02:53doesn’t it basically doesn’t need to

00:02:54figure those things out for you

00:02:57basically you are gonna tell it what

00:03:00type is what type is certain variables

00:03:02and all that kind of stuff so that’s

00:03:03going to give you some speed also it was

00:03:05just built from the ground up for

00:03:06concurrency whereas Python was kind of

00:03:08Python was built from the ground up to

00:03:10be a teaching language right and it just

00:03:13so happens that it’s so fun and so easy

00:03:15to program with that it got really

00:03:16really popular but that’s what Python

00:03:20was made for so pythons got the global

00:03:22interpreter lock kind of restricting it

00:03:24to one thread yes there are ways around

00:03:25that but that’s like band-aids over a

00:03:27bigger issue whereas go is just

00:03:31concurrent right out of the box so stuff

00:03:33like that is what’s gonna make go faster

00:03:35but go is much more pleasant to write

00:03:37then something like C++ anyways with

00:03:41that let’s go ahead and get into it I

00:03:43think you’ll learn a lot more about

00:03:44whether or not you like go by actually

00:03:47using go and seeing what you think from

00:03:49there so to get go it’s just go to

00:03:52golang.org head to the downloads and

00:03:55download whatever fits your needs so if

00:03:57you’re on Windows it’s just a simple

00:03:58Installer on Mac I have no idea its

00:04:00package I don’t know how installing

00:04:02that’s going to go for you I don’t use

00:04:03Mac and then on Linux it’s a total

00:04:05download that install that the only

00:04:07thing I’ll add is on Linux you’ll want

00:04:09to go ahead and export that path

00:04:11permanently if you don’t know how to do

00:04:13that I’ll put a link in the description

00:04:14to the tech space right up in this

00:04:15tutorial and you can head there for

00:04:19instructions on how to set it up on

00:04:21Linux a little more easily

00:04:24other than that you’re gonna need some

00:04:25sort of editor I’m gonna be using

00:04:27sublime text people like to make big

00:04:29deals about editors you can use whatever

00:04:30you want you can use notepad for that

00:04:32matter it doesn’t really matter sublime

00:04:35text is a great editor though so you can

00:04:37use that if you want that’s what I’m

00:04:39gonna be using and let’s go ahead and

00:04:41write our very first go program so I’m

00:04:45gonna go ahead and move this out of the

00:04:46way and I’ve just got a simple directory

00:04:49called go tux so I’m going to go ahead

00:04:50and just make a new file and I’m just

00:04:53gonna call it go to go yes we’re gonna

00:04:59open that up and we’re gonna get ready

00:05:00so the first thing in every go program

00:05:02it’s gonna be a part of a package and

00:05:04for the most part you’re gonna find

00:05:06yourself pretty much writing package

00:05:08mean every time until you start writing

00:05:10bigger things

00:05:11so package main and then you’re gonna

00:05:15have your imports for now we’re just

00:05:16going to import fmt and all your imports

00:05:19go in double quotes and something to get

00:05:22used to especially if you’re coming from

00:05:23Python which I assume many people

00:05:25viewing this or from my channel mainly

00:05:27watch Python you have to use double

00:05:30quotes also you’re putting quotes around

00:05:32your imports but get rid of single

00:05:35quotes you’re gonna be done using them

00:05:37with with go also if I if I slip up and

00:05:40call go python and all that kind of

00:05:41stuff I’m sorry it’s gonna happen I’m

00:05:43also probably gonna type like print a

00:05:45few times I’m also gonna make quite a

00:05:48few pun puns about go so get used to it

00:05:52so once you’ve done your imports we’re

00:05:53just gonna import fmt which is like

00:05:55format basically it’s gonna be how we

00:05:57can print something out basically we’re

00:05:59ready to build out our functions so to

00:06:01actually write a function you’re gonna

00:06:04say func that just start your function

00:06:06you’ve got your function name

00:06:08you’ve got parameters and then the

00:06:10function comes after that

00:06:11again it’s not Python unfortunately

00:06:13we’ve got braces so like many other

00:06:16languages so and then in here you write

00:06:19your code we’re just gonna have some

00:06:20simple code it’s just going to be FM T

00:06:22capital P print line and then we’re just

00:06:25going to say again in double quotes

00:06:27don’t use single quotes anymore welcome

00:06:29to go awesome so we can go ahead and

00:06:33save that and let’s run this program

00:06:35real quick so we’re going to come

00:06:37here I’m gonna open up the command line

00:06:39and to run it you just do go run and

00:06:43then whatever the file name is so for me

00:06:45it’s go touch go go hey dinner and but

00:06:49welcome to go so that’s going to go

00:06:51ahead and compile and run it for you at

00:06:53the same time so so that’s that not too

00:06:57much I really want to cover here until

00:06:59we get to the next tutorial like I said

00:07:01there’s just like a little things that

00:07:03you’ll have to get used to also you

00:07:04might be wondering why did the main

00:07:06function even run like we didn’t ask it

00:07:07to run great question so we’ll be

00:07:10talking about stuff like that in the

00:07:11next tutorial also be explaining a lot

00:07:13of little smaller things here that you

00:07:15might not have noticed if you have

00:07:17questions comments concerns go puns

00:07:19whatever feel free to steam them below

00:07:21otherwise I’ll see you in the next

00:07:22tutorial