Book Image

Network Automation with Go

By : Nicolas Leiva, Michael Kashin
Book Image

Network Automation with Go

By: Nicolas Leiva, Michael Kashin

Overview of this book

Go’s built-in first-class concurrency mechanisms make it an ideal choice for long-lived low-bandwidth I/O operations, which are typical requirements of network automation and network operations applications. This book provides a quick overview of Go and hands-on examples within it to help you become proficient with Go for network automation. It’s a practical guide that will teach you how to automate common network operations and build systems using Go. The first part takes you through a general overview, use cases, strengths, and inherent weaknesses of Go to prepare you for a deeper dive into network automation, which is heavily reliant on understanding this programming language. You’ll explore the common network automation areas and challenges, what language features you can use in each of those areas, and the common software tools and packages. To help deepen your understanding, you’ll also work through real-world network automation problems and apply hands-on solutions to them. By the end of this book, you’ll be well-versed with Go and have a solid grasp on network automation.
Table of Contents (18 chapters)
1
Part 1: The Go Programming Language
6
Part 2: Common Tools and Frameworks
10
Part 3: Interacting with APIs

Installing Go on your computer

The Go download and install instructions (https://golang.org/doc/install#install) require you to download a file from https://go.dev/ and follow a couple of instructions. We include here the steps for Go version 17.7, which is the latest version available at the time of writing. Newer versions of Go 1 should continue to work.

Windows

To install Go on Windows, follow these steps:

  1. Download https://golang.org/dl/go1.17.7.windows-amd64.msi.
  2. Execute the go1.17.7.windows-amd64.msi file and follow the instructions.
  3. Open the Command Prompt window (cmd) and run go version to verify the installation.

Mac

If you have Homebrew installed, you can run brew install go. Otherwise, you can follow these steps:

  1. Download https://golang.org/dl/go1.17.7.darwin-amd64.pkg.
  2. Execute the go1.17.7.darwin-amd64.pkg file and follow the instructions.
  3. Open a Terminal and run go version to verify the installation.

Linux

Go is typically available as a system package in a Linux distribution, but is often an older version. Follow these steps to install a more recent release:

  1. Download https://golang.org/dl/go1.17.7.linux-amd64.tar.gz.
  2. Remove any existing Go installation with rm -rf /usr/local/go.
  3. Extract the archive you downloaded into /usr/local with tar -C /usr/local -xzf go1.17.7.linux-amd64.tar.gz.
  4. Add /usr/local/go/bin to the PATH environment variable with export PATH=$PATH:/usr/local/go/bin. To make this persistent, add this line as well in $HOME/.bash_profile. This last part is valid for bash, but you might want to do something similar if you use a different shell.
  5. Run go version to verify the installation

There you go! You can now download and install Go in your system without any hassle. To install a different version, just replace 17.7 in the instructions with a target version of your choice.