Go

A fast, statically-typed language by Google designed for simplicity, concurrency, and building scalable systems.

Procedural
Concurrent
Beginner
2009
Robert Griesemer, Rob Pike, Ken Thompson (Google)

Overview

Go (or Golang) is an open-source programming language designed at Google. It is syntactically similar to C but with memory safety, garbage collection, structural typing, and built-in concurrency through goroutines. Go's simplicity and speed of compilation make it ideal for building cloud infrastructure, network services, and command-line tools. Docker, Kubernetes, and Terraform are all written in Go.

Key Features

  • Goroutines — Lightweight concurrent execution with channels for communication
  • Fast compilation — Compiles to native machine code in seconds
  • Simple syntax — Deliberately minimal; one way to do things
  • Built-in tooling — go fmt, go test, go vet, go mod out of the box
  • Static binary — Single binary deployment with no dependencies

Code Example

go
package main

import (
    "fmt"
    "sync"
)

func main() {
    var wg sync.WaitGroup
    messages := []string{"Hello", "from", "Go", "goroutines!"}

    for _, msg := range messages {
        wg.Add(1)
        go func(m string) {
            defer wg.Done()
            fmt.Println(m)
        }(msg)
    }
    wg.Wait()
}

Learning Resources

Learning Path

21 topics across 5 sections

1Basics

Go fundamentals — syntax, types, and program structure.

  • Introduction to Go — Why Go, installation, go run, and Hello World
  • Variables & Types — var, :=, basic types, zero values, and type conversion
  • Functions — Multiple return values, named returns, and variadic functions
  • Control Flow — if, switch (no break needed), for (the only loop), defer
  • Packages & Imports — Package system, visibility (capitalization), and go mod

2Data Structures

Go's built-in composite types.

  • Arrays & Slices — Fixed-size arrays, dynamic slices, append, copy, and capacity
  • Maps — Hash maps, iteration, delete, and comma-ok idiom
  • Structs — Field types, embedding, methods, and pointer receivers
  • Pointers — Address-of (&), dereference (*), and no pointer arithmetic

3Interfaces & Error Handling

Go's approach to polymorphism and errors.

  • Interfaces — Implicit satisfaction, empty interface, and type assertions
  • Error Handling — error interface, errors.Is/As, wrapping with %w, and sentinel errors
  • Panic & Recover — When to panic, defer+recover pattern, and stack unwinding

4Concurrency

Go's killer feature — goroutines and channels.

  • Goroutines — Lightweight threads, go keyword, and goroutine lifecycle
  • Channels — Unbuffered, buffered, directional channels, and close
  • Select — Multiplexing channels, timeout, and non-blocking operations
  • sync Package — WaitGroup, Mutex, Once, and Pool
  • Context — Cancellation, deadlines, and request-scoped values

5Advanced Topics

Production-ready Go techniques.

  • Generics (1.18+) — Type parameters, constraints, and generic data structures
  • Testing — go test, table-driven tests, benchmarks, and fuzzing
  • Reflection — reflect package, type inspection, and use cases
  • CGo — Calling C code from Go and performance considerations