Check out a free preview of the full Go for JavaScript Developers course:
The "Installing Go" Lesson is part of the full, Go for JavaScript Developers course featured in this preview video. Here's what you'd learn in this lesson:

Brenna describes the steps for installing Go, how to set up directories using the bash profile, and how to run a Go file in the terminal to verify everything is installed correctly.

Get Unlimited Access Now

Transcript from the "Installing Go" Lesson

>> So let's get into the installation process. So first of all, let's talk a little bit about what we'll need besides the actual Go language throughout workshop. I'll be working mostly in a code editor. I'll be in VS code. Option two is going to be the Go Playground, which I'll introduce you to in a later lecture.

[00:00:21] And your favorite browser, I'll be working in Chrome. But if you have a different browser you're into that's great too. So as we work through the workshops, there'll be exercise slides that come up throughout the day. On the upper right hand corner is going to be where that exercise file lives and it'll have instructions for what we're working on, kind of the goals of that exercise and anything I want you to keep in mind as you're working through it.

[00:00:45] For this particular exercise, we're just going to be installing the Go language. There are instructions. It's a bit of a complex process if you're not used to updating your Bash profile, so the actual instructions live in the exercise underscore zero dot markdown file, but we'll also kind of talk about them on the screen as well.

[00:01:04] So first things first, you're gonna want to go to golang dot org slash dl to install Go. And when you reach that website you'll see a series of options depending on what operating system you're working with. So once everyone has the Go Library successfully installed through the installation wizard, our next steps are to kind of coordinate what's happening on our local machines to match that installation.

[00:01:28] So the first thing we'd like to do is verify that Go was installed and to do that you'll run a couple of commands in your terminal. The first is which Go, which should print out to where that Go installation, put some of the Go executables. The second command is Go version and you should see Go 1.13 if you installed it today, and then after that we do need to add a couple things to our Bash profile.

[00:01:53] So what we've done so far is installed Go as a command, but Go doesn't know where it needs to access any files or executables that we'll install later on in the projects. So the three environment variables you need are up on the right hand corner, you'll need to define Gopath Gobin and then update your path to include Gobin.

[00:02:11] And so those lines of code you can add to anywhere in your Bash profile. After you define your path variable to begin with. To verify that those environment variables have successfully been updated, you might need to restart your terminal. But then if you run echo dollar sign path, you should see a bunch of stuff print out including somewhere in there the which Go series of paths that you kind of printed out at the beginning the user slash local slash go.

[00:02:38] And then if you run echo dollar sign Gopath you should see if it was the default download settings. Your home directory in slash directory go, so for me slash users slash Brenda Martinson slash go. The kicker here is that that Go directory hasn't actually been created yet. So we need to do that next but it is telling Go where it's going to find any executable files down the road.

[00:03:00] So for step four, we're going to create the actual Go work space, where we're going to put all the files that we use today and including cloning the repo for as we work through the workshops. So for looking at step four, creating a work space we'll want to navigate to whatever our Go path was defined to be.

[00:03:15] For me, that was my home directory of users slash Brenda Martinson. So I'm going to flip over to my terminal and walk through the rest of the setup to create our Go work space. So when I'm at my home directory, I see that the path I'm currently living in is users slash Brenda Martinson.

[00:03:39] And right now, when I ask what directories live here, you'll see I already have a Go directory, since I've been working in it today. If you do not, you want to make dir that Go directory and this is where we're going to put all of our Go files.

[00:03:52] Once you've made that directory we can change into it. And a typical Go directory is going to have three additional directories within it. You'll have a bin, a package and source directories. The one we care about today is that source directory SRC. That's where we're gonna put all of our Go files and also clone in our repo.

[00:04:11] So if you don't see that you're gonna make dir the source directory. And once you've created it, change into that. And then right now you'll see I have quite a few different projects yours will probably be empty. But in the source directory is where you're gonna wanna get clone and then the address to the repo.

[00:04:30] So to get clone that repo you'll go to the link on the slide and then run get clone. Once you have that installed, if you CD into the repo for the workshop today, and run, Go run main dot Go, you should see hello Frontend Masters print out and installation is complete