GopherCon UK - Advanced Go - Cory LaNou

Course Overview

Go is a modern programming language with a heavy focus on developer productivity, scalability, and speed. Concepts such as concurrent programming, testing, and performance testing were designed into the language from the beginning. If you want to learn about concurrent programing, or how to performance test and profile your code, this course is for you.

This course is for you because

  • You want to learn how to write concurrent software.
  • You want to learn best practices for writing tests and benchmarks.
  • You want to use the built in tools to profile and measure performance of your software.


  • A working knowledge of a modern programming language (Java, Ruby, Python, C, C++, C#, Perl, etc.)
  • A basic understanding of operating system concepts and environment variables.
  • Experience working with a command shell and navigating a filesystem.
  • At least 6 months of Go programming experience.

Course Outline


Concurrent programming in many environments is made difficult by the subtleties required to implement correct access to shared variables. Go encourages a different approach in which shared values are passed around on channels and, in fact, never actively shared by separate threads of execution.This module covers Go routines and how to synchronize communication between them. Mechanics for synchronization such as WaitGroups, Mutexs, and Channels are explored along with the corresponding patterns for each. Find out the difference between a buffered and unbuffered channel, and when to use them. Also discover how to use channels for signaling for concepts such as graceful application shutdown.


Go ships with a powerful testing framework. Tests in Go are written in the Go language, so there is no need to learn another syntax. This module will explore basic tests, table driven tests, and sub-tests. Concepts such as race conditions, code coverage, test automation. Understanding test options such as parallel, short testing, timing out tests, and verbose are also covered.


Go comes with a powerful set of tools for profiling and improving the performance of your code. Benchmarking is one of those tools, and the first one most developers start with. In this module we will cover basic benchmarking, some common benchmarking mistakes, and how to compare benchmarks to see if performance has improved.


Go ships with a number of profiling tools. This chapter will walk you through how to:

  • Use interactive pprof with a cpu profile
  • Use interactive pprof with different types of memory profiles
  • Generate profiles from benchmarks
  • Generate profiles from live/running applications
  • Generate torch graphs from benchmarks or live/running applications


Delve is a source level debugger for Go. In this module, we will learn how to launch Delve and interactively debug a program.

Building And Compiling Go Applications

Go has the ability to build and cross compile with ease. This chapter will cover the different ways to build your binary and additionally covers concepts for embedding build information such as version and GitHub SHA-1 hash. See how build tags are used to conditionally include specific branches of code by targeting specific platforms or simply using the tags provided.


This module covers where to get more support on Go, recommends books and videos, and list contact information for your instructor.

If time permits, we will also cover

Testing Asynchronous Tasks

Many times you may be testing parts of your code that have service dependency that run for an unknown amount of time. Examples of these may be task queues, distributed system calls, etc. Because you don't know how long they may take to execute, testing them can present some challenges. In this module we will learn how to set up tests both effectively and efficiently for testing async processes.

Mocking Tests

It's easy to decouple packages in Go using interfaces. Because of this, testing can also be much easier. However, you typically want to mock out your interfaces in tests so that unit testing is much easier. This chapter will cover how to write a mock for a service to enable easy and precise testing.