Training

Introduction to Go

This is a one day workshop for folks who already have experience with another programming language and want to get an introduction to programming in Go. The workshop is in two parts; before lunch we focus on the basics of syntax and language specific concepts using an interactive online IDE. After lunch is dedicated to kata style exercises in Go.

This workshop assumes you have prior experience with another common programming language; Python, Java, Ruby, Perl, Javascript, C, for example. This workshop will show you how to apply your existing knowledge to Go. As the workshop assumes no knowledge of Go, if you have written some Go code, you may find the morning session boring or repetitive.

Syllabus

  • Syntax

    An introduction to the basic syntax of the language; numbers, expressions; addition, subtraction, etc, variables, assignment, arrays, slices and subslices, loops, conditionals, switch, and functions

  • Language details

    In this second section we’ll revisit each of the topics of the previous section and expand on each; literals, identifiers, types, structs, constant expressions, zero values, short declaration syntax, scopes, constants, range, pointers, nil, and methods.

  • Development environment

    This section focuses on the developer experience, installing Go and setting up a $GOPATH workspace, introduction to the go command, and writing unit tests with the go test command.

  • The standard library

    Go ships with a rich standard library of packages. This section will focus on the important packages from the standard library with exercises.

  • Packages and applications

    The final section will focus on designing your own reusable Go packages and combining those into complete applications.

Prerequisites

  • Each student should have experience with a programming language other than Go.
  • Each student must provide their own laptop with permission to install software.
  • A reliable internet connection at the training venue is required.

Outcomes

At the end of the day you will be able to:

  • Install Go and configure your development environment.
  • Learn the syntax and structure of Go programs.
  • Learn to write and test Go packages.
  • Learn to build complete Go applications.

Materials:

All training materials are supplied under a CC-SA 4.0 licence


High Performance Go

The goal for this workshop is to give you the tools you need to diagnose and fix performance problems in your Go applications.

Through the day we work from the small — learning how to write benchmarks, then profiling a small piece of code. Then step out and talk about the execution tracer, the garbage collector and tracing running applications. The remainder of the day will be a chance for you to ask questions, experiment with your own code.

This workshop is available in full day and half day lengths.

Syllabus

  • Benchmarking

    How to write effective benchmarks, and how to interpret their results. This section includes some traps for young players and advice for how to avoid them.

  • Profiling

    How to use the tools built into the Go runtime, and other tools like perf(1) to gain an understanding on what your code is doing.

  • Compiler optimisations

    The Go compiler performs many of the classical optimisation passes found in modern compilers. This section will discuss the operation of the three most important ones; inlining, escape analysis, and dead code elimination.

  • Understanding the execution tracer

    Unlike sample based profiling, the execution tracer is integrated into the Go runtime, so it doesn’t just know what a Go program is doing at a particular point in time, but why. This section will demonstrate the usage and interpretation of the results from, the execution tracer.

  • Memory management and GC tuning

    As Go is a garbage collected language, understanding, and working with the garbage collector is a large part of writing performant applications.

  • Concurrency

    The final section focuses on using (and not overusing) Go’s concurrency features.

After each section there will be ample time for questions from the students.

Once all the sections are complete the remainder of the time will be dedicated to assisting the students in applying the material to their own projects.

Prerequisites

  • Each student must provide their own laptop with a current working Go environment.

Outcomes

At the end of the day you will be able to

  • Write reliable benchmarks.
  • Profile existing programs.
  • Identify common bottlenecks.
  • Address performance bottlenecks and measure the result.

Who should attend

  • Familiarity with the Go programming language is assumed. This is not an introductory course on Go programming.
  • Students should have written and deployed a Go application to production.

Materials:

All training materials are supplied under a CC-SA 4.0 licence