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 cover 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 in Go, why might you be interested in 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 pythonprogramming.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. We could make some serious speed gains there and
in web development the difference of 100ms is a major difference, especially when you scale that out to millions of users.
You know the speed doesn't just affect
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 gains 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 where 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 tar, 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 after 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 gotuts, so I'm going to go ahead and just make a new file
And I'm just gonna call it gotut.go
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 main 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
fmt.Println 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 gotut.go
hit Enter
And Boom, 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 stream them below. Otherwise, I'll see you in the next tutorial