Install and Setup
The course is part of this learning path
If you're thinking about engineering the next big dotcom application then you should seriously consider using Go!!
The Go Programming Language is without doubt one of the hottest languages to learn, particularly in this cloud native era. More and more companies are adopting Go to engineer highly performant, stable and maintainable applications. Popular projects such as Docker, Kubernetes, Terraform, Etcd, Istio, InfluxDB have all been built successfully using Go!!
This introductory level training course is designed to bring you quickly up to speed with the many key features that the Go programming language provides. You'll also learn how to setup your own Go development environment - consisting of the Go toolchain, Visual Studio Code, and several related Go based extensions - all to ensure that you are able to be productive writing your own source code.
We’d love to get your feedback on this course, so please give it a rating when you’re finished. If you have any queries or suggestions, please contact us at email@example.com.
By completing this course, you will:
- Learn about what makes Go a great language
- Learn how to install the Go toolchain
- Learn how to setup Visual Studio Code to edit and debug Go programs
- Learn how to work with the Go Playground to test and run snippets of Go code
- Learn and understand the basic Go language syntax and features
- Learn how to use the Go tool chain commands to compile, test, and manage Go code
- And finally, you’ll learn how to work with and manage Go modules for module dependency management
This course is intended for:
- Anyone interested in learning the Go Programming Language
- Software Developers interested in using Go to compile and test Go based applications
- DevOps practitioners looking to learn about Go to support Go based applications
To get the most from this course, you should have at least:
- A basic understanding of software development and the software development life cycle
All sample Go source code as used and demonstrated within this course can be found here:
- [Jeremy Cook] Welcome back. In this lecture I'm going to demonstrate just how easy it is to download and install Go. One of the key benefits associated with building Go based applications is that it is quick and easy to install the build tool chain. Go provides installers for all of the popular operating systems, Linux, MacOS, and Windows. This demonstration will be performed on a Mac, but the basic techniques are compatible regardless of operating system. For starters, navigate to the golang.org website. This website provides entry points to not just the downloadable installers, but also to the documentation that details how to work with the compiler and other related command line utilities. It also provides detailed information about all of the packages that Go provides in the standard library. For now, we want to navigate to the installers. I'll do so by clicking on the Download Go button. Next, in the feature downloads section, I'll download the MacOS installer. Once the installer has completed downloading, its just a simple case of kicking it off and accepting the defaults and waiting for the installer to complete. After the installer completes, we can then jump into the local terminal and examine the installation.
First up, I'll run the command, "which go" to determine the directory on the file system as to where the go binary was installed. Here we can see on my system it's being placed in the "/usr/local/go/bin/" directory. Next, I'll run the command "go version" to determine the version details of Go, in this case you can see that we've installed version 1.13. Typing go by itself displays the help which documents all of the sub commands that can be used. For example we can see the explanation for the env, environment command, this as the explanation states, "prints the local Go environment information" lets try this out. Here we can see the results for running the command, "go env". Now, each of these environment variables are specific to the local Go installation. I won't go through them all individually but I will highlight the following: GOROOT, is a variable that defines where your Go SDK has been installed to and GOPATH, is a variable that defines the root of your development workspace. The Go tool chain expects a certain layout of the source code.
The GOROOT and GOPATH environment variables are used to configure the directories where source code is and will be located. Now that we have installed the Go SDK, which has installed the go build tool chain and the go standard library we can actually start editing and compiling. As a quick demonstration let me show a simple example. Staying within the terminal, I'll use the cat command to create a simple GO file named, hello.go containing the contents as seen here. We can confirm that the source code has been written and saved into the hello.go file by again using the cat command to display the contents of the file like so.
Okay, this looks good. Next, I'll execute the command, "go run hello.go". This command will quickly compile and execute the program all in one hit. Here we can see indeed that this has been successful, since the program has indeed printed out the string, "Hello from CloudAcademy". Now, although we have successfully proven that our go tool chain and sdk are installed and functional, we don't really want to be authoring code using the terminal. Instead we should really consider using an IDE to make us more productive.
This is what we'll do in the next demonstration, by installing and setting up Visual Studio Code.
Jeremy is the DevOps Content Lead at Cloud Academy where he specializes in developing technical training documentation for DevOps.
He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 20+ years. In recent times, Jeremy has been focused on DevOps, Cloud, Security, and Machine Learning.
Jeremy holds professional certifications for both the AWS and GCP cloud platforms.