Course info
Feb 28, 2018
2h 8m

The Go language has made a name for itself by embracing simplicity as a core design concept. This does not just extend to the language; it touches every aspect of the Go ecosystem. This course, The Go CLI Playbook, covers many aspects of the Go command line tool which, in keeping with the Go philosophy, provides a single point of entry for all the core activities involving the language, including retrieving third party packages, building projects, and executing tests. First, you’ll learn how to use the Go command to compile your applications, both as standalone entities and as libraries that can be shared with Go and non-Go programs. Next, you’ll explore how to test applications including performance profiling. Finally, you’ll examine how to manage workspaces and explore the environment that Go is working in. By the end of this course, you'll have the necessary skills and knowledge to access the full power that the Go CLI offers.

About the author
About the author

Michael Van Sickle is an application architect in Akron, Ohio. He is a mechanical engineer by training and a software engineer by choice. He is passionate about learning new programming languages and user experience design.

More from the author
Go: The Big Picture
1h 47m
May 22, 2019
Intern 4: Getting Started
2h 41m
Jan 9, 2018
More courses by Mike Van Sickle
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi everyone. My name is Michael Van Sickle, and welcome to my course, The Go CLI Playbook. One of the Go language's core philosophies is simplicity. One of the most obvious places that expresses itself is in the language where a few key words are used in predictable ways to enable the creation of programs that are not only powerful, but easy to understand. However, Go doesn't stop there. Having an easy to understand language doesn't help much if it's difficult to set up a development environment. In this course, we're going to explore the go CLI command and see how it provides a single point of entry for all of the critical tasks involved with programming with Go. Some of the major topics that we'll cover is include learning how to build libraries and binaries that can be used on their own or shared with other programs, both those written in Go and those that aren't; exploring Go's testing capabilities, including its ability to create code coverage reports and performance profiles; the go commands that helps maintain your workspaces and ensure that your source code is as error free as possible; and finally, we'll discover how the go command can be used to gain insight into the development environment that Go is running in. By the end of this course, you'll know how to use all of the major commands that the Go CLI offers. Before beginning the course, you should be familiar with the basics of the Go language itself, but you don't need to be an expert. I hope you'll join me on this journey to learn about the go command with The Go CLI Playbook course at Pluralsight.

Hello, and welcome to the course. Over the next couple of hours, we're going to be learning about the Go language's command line tool and many of the options that it offers. This is a playbook style course, so you're going to be seeing a lot of demos. First, however, let's kick things off with a bit of an introduction. So in this module, we're going to get ourselves oriented by getting a brief introduction to the go command itself. We're going to be talking about some prerequisites that are going to be useful to be familiar with before you take this course, and then I want to give you some advice on how to navigate this course. If you've been using Pluralsight for a while, you might be used to courses that start at module 1, and you keep watching clip after clip until you get to the end of the course. Well, this is a playbook style, and it's structured a little bit differently, so we'll talk about that at the end of this module. Okay, let's get started by introducing the go command.

Building and Running Programs
Hello, and welcome back. In this module, we're going to tackle the commands that the Go CLI offers that enable us to build and run our Go programs. We're going to start with three main commands here. We're going to start with go run that enables us to run our Go programs without leaving any compilation artifacts on our disk. We're then going to move into go build. It's going to allow us to build our libraries and our executables. And then we're going to finish up with go install, which is going to not only build our executables in our libraries, but it's going to install them in the appropriate places in our Go environment. And that's going to be all of the commands that we're going to cover in this module. However, we do have a little bit more material that I want to go over. The go run, build, and install commands in and of themselves are very powerful, but there's a lot of options that are available to influence how those commands function, so we're going to take a few minutes and go through and talk about some of the specific build flags that you might use to influence how your Go binaries and libraries are built. And finally, we're going to take another specialization even from the build flag section, and we're going to talk about the build modes that are available with Go. So in this section, we're going to talk about how build standalone libraries, how to build plugins, and how to build libraries that will interop with C programs. Okay, so let's get started by talking about the go run command.

Testing Programs
In the last module, we talked about the different options that Go offers to compile our applications and libraries. In this one, we're going to talk about the final way that we can compile our Go applications. This one adds the tests into the compiled application and offers us insight into how our application is performing. We're going to break this module down like we broke down the previous one. We're going to start with the basics. We're going to start with how to execute our tests and the various flags that we have available when we're executing our tests and how those can influence how those tests are run. Then we'll talk about how we can generate code coverage reports so that you can determine what code in your application is not being covered by your test suite so that you can ensure that your tests are as thorough as possible. Then we'll talk about benchmarking tests and how we can change how we're going to execute our tests a little bit so that we can determine if our application is performing as quickly as we expect. And then finally, we'll talk about some profiling tools that are available when you're running your test suite so that not only can you determine if your application is behaving as you expect, but you can also monitor resource utilization to ensure that your application is being a good steward of the resources of the computer that it's running on. Okay, so let's get started by learning how to execute our test suites for our Go applications.

Managing Workspaces
In the last module, we talked about the test command and in the process wrapped up our discussions about the options that Go CLI offers us for compiling our applications. In this module, we're going to zoom out a bit and talk about the commands that are targeted at helping us manage Go workspaces. There are four topics that we're going to cover in this module. The first is the options that we have for cleaning our workspaces. Then we'll talk about how we can format our source code automatically using the go command. We'll talk about how we can verify that our source code is meeting best practices by vetting our programs. And finally, we'll touch on the topic of generating source code with Go. Now source code generation is a pretty broad topic, so we're not going to be able to get too far into that, but we will touch on it and see how the go command can be used to kick off that process. Okay, so let's get started by talking about how to clean our workspaces.

Interacting with the Environment
In the beginning of this course, we talked about the commands that the Go CLI offers us to build and test our Go applications. In the last module, we zoomed out to the workspace level and explored the support that we got there. In this module, we're going to zoom out to the scope of the development machine itself and examine the support that the CLI is going to give us at that level. There are three major categories that we're going to explore at this level. The first is the commands that are offered to us to allow us to explore the global environment or the environment on the development machine itself. Then we're going to talk about how we can retrieve libraries to provide functionality to our Go applications that we don't have to write. And then finally, we're going to talk about to report an issue just in case you find a bug with Go or one of the standard libraries. Okay, so let's get started by learning how to explore the global environment.