O'Reilly logo
live online training icon Live Online training

An Introduction to Go for Systems Programmers and Web Developers

Learn Go and develop UNIX system utilities

Mihalis Tsoukalos

Go is a modern and very popular open source programming language that started as an internal Google project and was officially announced at the end of 2009. The advantages of Go include code that is portable, secure, easy to read, write and understand, support for concurrent programming and garbage collection, a rich standard library, support for Unicode and executable files that are statically linked as well as support for web applications and a web server that can be used for testing purposes. Last, Go is a relatively easy to learn programming language provided that you spend the necessary time to study it.

In this live hands-on course you will be introduced to the Go programming language using as many examples as possible and you will learn how to write and execute Go programs, how to use the data types of Go, how to create your own structures, how to create Go packages, how to create and use goroutines, channels and pipelines, how to generate random numbers, how to organize your Go code into packages, how to work with slices and arrays as well as how to create TCP and HTTP servers and clients.

What you'll learn-and how you can apply it

  • Work with Go data types and composite types
  • Develop basic UNIX command line utilities
  • Develop applications that use multiple goroutines, channels and pipelines
  • Create a basic web server and a web client in Go
  • Develop a TCP server in Go
  • Develop a TCP client in Go

This training course is for you because...

  • You're a UNIX developer
  • You're a administrator
  • You're a web developer coming from programming languages such as Python, C, Perl, Ruby and PHP that want to start developing system tools, web and TCP/IP applications in Go as well as anyone interested in developing command line utilities and applications that work over network in Go.

Prerequisites

  • A working UNIX system like Linux and macOS
  • Any UNIX system with a recent Go installation will do
  • Basic knowledge of a UNIX shell – the bash shell will be used in this Live Course but you can use any UNIX shell you like.

Recommended preparation:

Materials, downloads, or Supplemental Content needed in advance:

  • A recent Go installation
  • A text editor such as vim, Emacs or TextMate

About your instructor

  • Mihalis Tsoukalos is a UNIX administrator, programmer, DBA, and mathematician, who enjoys writing technical books and articles and learning new things. He has written more than 250 technical articles for many magazines including Sys Admin, MacTech, Linux User and Developer, USENIX; login:, Linux Format, and Linux Journal. His research interests include databases, operating systems, Statistics, and machine learning.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

DAY 1

Section 1: A gentle introduction to Go (30 mins)

  • About Go
  • Installing Go on macOS
  • Installing Go on Linux
  • Finding out your Go version
  • The advantages of Go
  • What you will need to know
  • About the UNIX operating system
  • A simple Go program (Hello World!)
  • Explaining the Go program

Section 2: An introduction to Go data types, Functions and Packages (2h)

  • Go data types
  • Go Arrays and Slices
  • Go Maps
  • The error type
  • Go loops
  • Go functions
  • The defer keyword
  • Go packages
  • Getting user input and printing output
  • Two useful Go utilities: gofmt and godoc

BREAK (7 mins)

Hands-on Lab 1: Compiling and Executing Go code + Go data types (20 mins practice + 10 mins solution)

  • Executing the Go version of the Hello World program
  • About := and =
  • Working with Go data types and data structures

Hands-on Lab 2: Creating a Go package (20 mins practice + 10 mins solution)

  • Finding out information about a Go function
  • Copying an array into a slice
  • Error handling
  • Creating a Go package

BREAK (7 mins)

Section 3: Introduction to Go Strings, Runes and Composite Types (1h30)

  • Structures
  • Strings
  • Runes

Hands-on Lab 3: Generating Random numbers in Go (15 mins practice + 15 mins solution)

  • Working with runes
  • Creating a structure
  • About random number generation
  • Developing the program

DAY 2

Section 4: Introduction to Goroutines, channels and pipelines (2h)

  • About concurrency
  • Goroutines
  • The sync Go package
  • Go channels
  • Go pipelines

Hands-on Lab 4: Goroutines (20 mins practice + 10 mins solution)

  • Creating goroutines
  • Synchronizing goroutines
  • Creating a channel
  • Creating a pipeline

BREAK (7mins)

Section 5: A simple TCP server and Client (1h)

  • About TCP/IP
  • About TCP and IP

Hands-on Lab 5: Developing the TCP server and the TCP client (20 mins practice + 10 mins solution)

  • Develop a TCP server that returns random numbers
  • Develop a TCP client

BREAK (7mins)

Section 6: Creating a Web server and a Web client in Go (30mins)

  • About HTTP
  • Creating a web client
  • Creating a web server

Hands-on Lab 6: HTTP Clients and Servers (20 mins practice + 10 mins solution)

  • Developing web clients
  • Developing web servers