Press "Enter" to skip to content

Introduction – Go Lang Practical Programming Tutorial p.1


what’s going on everybody and welcome to
a go programming tutorial series this
tutorial series is going to be practical
and applied but also over the basics of
go the reason why I want to do it that
way is because the go programming
language I mean all programming
languages are like this but the go
programming language because it’s kind
of a low-level programming language it’s
kind of the case that you could go
through a basics tutorial for something
like go and feel like you kind of
understood what was going on and then
you actually go to try to apply it to a
project or something and you’re like I
have no idea how to do this right so so
my hope is that each time we learn
something we’re going to apply it to an
overarching objective and project and my
hope is that that’ll that’ll make
learning go much much simpler but still
even at the end of that the best way to
learn something is to keep trying to use
it to solve various types of tasks so
some of that’s actually still going to
be on you but hopefully I can make some
of that initial process easier so first
of all why go why would someone like me
be interested and go why might you be
interested and go basically go is built
from the ground up it was built by
Google it was built to solve Google
types of problems right so basically go
is for scale this would be like a
systems language web development
language anything you want to scale
anything you want to be super efficient
but you might not want to write in C++
so for example the reason I’m interested
in go is mainly for web development so a
website like Python programming net for
example it’s built in Python using flask
and it’s not the slowest website in the
world but it’s also not the fastest
website in the world it could we could
make some serious speed gains there and
in web development the difference of 100
mil or 100 milliseconds is a major
difference especially when you scale
that out to millions of users so it you
know the speed doesn’t just affect user
the user experience but it also affects
your bottom line how much are you paying
for processing cost basically right in
hosting time and all of that so anywhere
you can make gains in web development
it’s usually a very good thing and then
the bigger the scale the better those
are for you also in terms of just
anything where you need it to be super
fast or super efficient go is pretty
much C++ speeds so anywhere well that’s
a good thing to you maybe you’re in
high-frequency trading or something like
that where you you really want to be as
quick as possible but maybe you don’t
want to write something as tedious as C
so go is gonna be static typed like C++
unlike Python so every time like in
Python every time the interpreter hits a
variable has to kind of figure out what
is that variable and that variable could
change types and stuff like that and by
that I mean like int sand floats and
strings stuff like that
whereas in go that’s not the case so it
doesn’t need to know all there it
doesn’t it basically doesn’t need to
figure those things out for you
basically you are gonna tell it what
type is what type is certain variables
and all that kind of stuff so that’s
going to give you some speed also it was
just built from the ground up for
concurrency whereas Python was kind of
Python was built from the ground up to
be a teaching language right and it just
so happens that it’s so fun and so easy
to program with that it got really
really popular but that’s what Python
was made for so pythons got the global
interpreter lock kind of restricting it
to one thread yes there are ways around
that but that’s like band-aids over a
bigger issue whereas go is just
concurrent right out of the box so stuff
like that is what’s gonna make go faster
but go is much more pleasant to write
then something like C++ anyways with
that let’s go ahead and get into it I
think you’ll learn a lot more about
whether or not you like go by actually
using go and seeing what you think from
there so to get go it’s just go to
golang.org head to the downloads and
download whatever fits your needs so if
you’re on Windows it’s just a simple
Installer on Mac I have no idea its
package I don’t know how installing
that’s going to go for you I don’t use
Mac and then on Linux it’s a total
download that install that the only
thing I’ll add is on Linux you’ll want
to go ahead and export that path
permanently if you don’t know how to do
that I’ll put a link in the description
to the tech space right up in this
tutorial and you can head there for
instructions on how to set it up on
Linux a little more easily
other than that you’re gonna need some
sort of editor I’m gonna be using
sublime text people like to make big
deals about editors you can use whatever
you want you can use notepad for that
matter it doesn’t really matter sublime
text is a great editor though so you can
use that if you want that’s what I’m
gonna be using and let’s go ahead and
write our very first go program so I’m
gonna go ahead and move this out of the
way and I’ve just got a simple directory
called go tux so I’m going to go ahead
and just make a new file and I’m just
gonna call it go to go yes we’re gonna
open that up and we’re gonna get ready
so the first thing in every go program
it’s gonna be a part of a package and
for the most part you’re gonna find
yourself pretty much writing package
mean every time until you start writing
bigger things
so package main and then you’re gonna
have your imports for now we’re just
going to import fmt and all your imports
go in double quotes and something to get
used to especially if you’re coming from
Python which I assume many people
viewing this or from my channel mainly
watch Python you have to use double
quotes also you’re putting quotes around
your imports but get rid of single
quotes you’re gonna be done using them
with with go also if I if I slip up and
call go python and all that kind of
stuff I’m sorry it’s gonna happen I’m
also probably gonna type like print a
few times I’m also gonna make quite a
few pun puns about go so get used to it
so once you’ve done your imports we’re
just gonna import fmt which is like
format basically it’s gonna be how we
can print something out basically we’re
ready to build out our functions so to
actually write a function you’re gonna
say func that just start your function
you’ve got your function name
you’ve got parameters and then the
function comes after that
again it’s not Python unfortunately
we’ve got braces so like many other
languages so and then in here you write
your code we’re just gonna have some
simple code it’s just going to be FM T
capital P print line and then we’re just
going to say again in double quotes
don’t use single quotes anymore welcome
to go awesome so we can go ahead and
save that and let’s run this program
real quick so we’re going to come
here I’m gonna open up the command line
and to run it you just do go run and
then whatever the file name is so for me
it’s go touch go go hey dinner and but
welcome to go so that’s going to go
ahead and compile and run it for you at
the same time so so that’s that not too
much I really want to cover here until
we get to the next tutorial like I said
there’s just like a little things that
you’ll have to get used to also you
might be wondering why did the main
function even run like we didn’t ask it
to run great question so we’ll be
talking about stuff like that in the
next tutorial also be explaining a lot
of little smaller things here that you
might not have noticed if you have
questions comments concerns go puns
whatever feel free to steam them below
otherwise I’ll see you in the next
tutorial
Please follow and like us:

Be First to Comment

Leave a Reply