Expanded Library

The Go CLI Playbook

What you'll learn

In this project, you will learn how to use the Go command line interface.

You will get to know how to:

  • print environment information
  • format source code
  • get and install packages
  • import missing packages
  • run commands on existing source code

Table of contents

Setup
10m
  • Set up your local environment for this project. We'll walk you through everything you need to know, including how to install and configure your environment to be able to complete all of the tasks.
Print environment information using go env
10m
  • This module will provide information about retrieving the environment information in go. Then you can examining the go environment manually or through a tool like grep.
Format source code using go fmt and gofmt
10m
  • This module teaches how to use the format sub-command and the standalone program to format Go programs. It also touches a bit on the design decisions for formatting of Go programs.
Download and install packages using go get
8m
  • This module will teach you how to use go get to download and install packages. We will learn the go get command and what needs to be provided to it.
Compile and install packages using go install
8m
  • This module will teach you how to use go install to compile and install packages. We will learn the go install command and what needs to be provided to it.
Import missing packages
12m
  • This module focuses on the use of the standalone program called goimports, which is used to import missing packages.
Print the document for a function
10m
  • This module will teach you how to use go doc to prints the documentation for a function Similarly, the command can be used to print the documentation for a package, a variable, or a method.
Scan for directives and run commands on existing source code
12m
  • This module will teach you how to use go generate to scan for directives, run commands, and modify existing *.go source files.

About the author

Hong Xiao is a professional software developer since 2012. During the years, he is involved in different phases including designing, implementing, testing, and debugging of several successful software projects. He is a professional developer of programming languages including Java, .Net, Python and ECMAScript/Javascript, and he is an everyday user of scripting languages including Shell/Bash and PowerShell.

Ready to upskill? Get started