Go Toolchain
Getting up and running with Go is going to be a three‑step process. Now, there's a lot of different options that we could pursue, we're going to pursue one, and the one that I've chosen here is what is generally considered the most accessible option. It's going to work no matter what operating system you're running on, it's also going to work without any kind of paywall involved, so you're not going to have to make any investment to set up a development environment that's going to reflect what I'm going to be using. First, we need to install the Go toolchain
The Go toolchain
First, we need to install the Go toolchain. We need to install Go and all of the tools that are involved with it.
What is Go's toolchain?
Well, there are a set of common tools that are required for the creation of most programs. We have to be able to build our programs, we have to be able to test our programs, we might have dependencies, we might have third‑party libraries that we're going to import to leverage so our programming is faster and we can get to the end product more quickly. Then we might have things like documentation, we might have the requirement to create technical documentation. We have performance profiling to make sure that our applications are as performant as necessary. We have application tracing just in case our applications aren't as performant as possible. We use tracing to figure out why aren't they performing the way that they need to? So, all of these tools, in many languages we have a lot of different pieces that we have to put together to build this toolchain, to build this development environment.
Well, with Go we have the advantage that everything is built into the Go command. So when you install Go, when you install that Go toolchain, you're going to get the capability to build, profile, test, manage dependencies, manage your code, create documentation, and trace your applications, as well as quite a few other things. So when we talk about installing the Go toolchain, it's actually going to be a lot simpler than you might see in other languages.
Installing Go's toolchain
Go to Go projects home page at go.dev. Now you can see download button. Now when we click on that Download button, we're going to be taken to this page that's going to walk you to the Featured downloads. So these are the most commonly installed versions of the Go toolchain, and it depends on the operating system that you're on. So if you're running on Microsoft Windows, then you'll use this first option, if you're running on a Mac, then you'll use this second option or third option, depending on your processor type, and so on. For Linux you're going to have this last option on this first row. If you do need Go in other languages, and Go works with lots of different languages, then as you scroll down you're going to see some additional options that are available to us.
Now, if you're downloading for Windows or Mac, the job is really simple because you're just going to download an installer, an msi package for Windows or pkg package for Mac, and your system's installer is going to automatically install Go for you after you download that package and start it running. For Linux it is a little bit more complicated. For that you're going to download the tar.gz file, and then if you come to this installation instructions link and select your operating system, which would be Linux, then you're going to see the commands presented right there. You see the command that's going to allow Go to be installed, and then you do have to install Go onto your terminal's path. That's automatically done with the Mac and Windows installers, but with Linux we do have to go that extra step to add that to our path and our user profile.
To find out if you've done it successfully what I would encourage you to do is open up a terminal, like I've got right below, and then type the go command and then the word version afterward. When you run that you should see the latest version of Go present a version message on your screen, and it should list your operating system and platform that you're running on.
As you can see above, I'm running 64‑bit Windows, and so that's the information that I get. so that's all it takes to get Go installed. Now, what does that give us? Well, if we simply type the Go command, we're going to see that there are a lot of options available to us. If You look below a little bit, notice the commands block right here. I've got the ability to report a bug if I find a bug in the Go language, I can build my applications, create documentations, I have the ability to format my code, I have the ability to use this get command to retrieve dependencies, and many more options. so that's the Go toolchain installed. Notice, we don't have to install anything else. Testing is built into the Go toolchain, building is built in the Go toolchain, dependency management is built‑in. So if you come from a language that requires multiple tools to get a similar experience, well, get used to this because with Go we tend to have this batteries included, everything's included to minimize the overhead that we have setting up a Go development environment and building our Go program.
In next blog we're going to set up our code editor.
Reference
Pluralsight- Go Fundamentals