About the Go Language
Get an overview of the Go language.
We'll cover the following
Introduction to the Go language
Go is a modern programming language that combines the reliability provided by the compilation process with the flexibility of dynamic typing. Go’s ease of use and flexibility in prototyping new ideas make it a great choice for writing command-line tools. At the same time, Go allows the implementation of more complex scenarios by providing features like type safety, cross-compilation, testing, and benchmarks.
Many popular command-line tools we use are developed with Go. These include Docker, Podman, Kubectl, Openshift CLI, Hugo, and Terraform. If you’ve ever wondered how similar tools can be made, this course is for you.
We’ll apply our knowledge of Go’s basic syntax and also employ more advanced concepts to develop several command-line applications. We can use these applications to automate tasks, analyze data, parse logs, talk to network services, or address other system requirements. We’ll also employ different testing and benchmarking techniques to ensure our programs are fast and reliable.
Go modules
The code examples in this course rely on Go modules, the standard method to
control and manage package dependencies for Go applications. By using Go
modules, we can write our Go programs outside of the legacy $GOPATH
required by older versions of Go prior to 1.11. Modules also enable reproducible builds as they record the specific version of Go and the external
packages required to reliably build the application. We can find more information about Go modules in the official Go blog posts, Using Go Modules
and New module changes in Go 1.16.
To follow the examples, we’ll need to use Go 1.13 or greater, with modules enabled.
Modules provide a standard way to group related packages into a single unit,
which can be versioned together. They also enable consistent dependency management for our Go applications. To use modules, we create a directory for our code and use the go mod init
command to initialize a new module, along with a unique module identifier. Typically, the unique module identifier is based on the version control path used to store the code.