Go – Generic Programming (GO3)

Programming, Rust

This course teaches how to build reusable, type-agnostic code using Go's generics model introduced in Go 1.18. You will learn to design generic functions, declare type parameters, and apply constraints and interfaces to create robust collections, utilities and APIs.

Hands-on exercises focus on implementing generic collections, common utilities and API design, comparing Go's approach with C++/Rust. You will practice type inference, debug compiler errors, measure performance and binary impact, and apply idiomatic workarounds.

Location, current course term

Contact us

Custom Customized Training (date, location, content, duration)

The course:

Hide detail
  • Introduction to generics (Go 1.18+)
    1. Syntax of type parameters, constraints (~, |, type sets)
    2. Built-in constraints (comparable, any) and custom constraints
  • Generic functions and types
    1. Writing general utilities (Min/Max, filters, transforms)
    2. Generic collections and algorithms (sorting, searching)
    3. Type composition and methods on generic types
  • Interfaces and generics
    1. Connecting interfaces and type parameters, API design
    2. When to choose interface-based polymorphism vs generics
  • Errors and inference
    1. Type inference vs explicit types, readability and compile errors
    2. Generics limitations in Go and idiomatic workarounds
  • Performance and readability
    1. Impact of generics on binary size and runtime performance
    2. Maintainability, documentation and tests (table-driven with types)
Assumed knowledge:
Basic experience with Go and familiarity with Go 1.18+ features.
Recommended previous course:
Go – Advanced Techniques (GO2)
Recommended subsequent course:
Go – parallel programming (GO4)
Schedule:
3 days (9:00 AM - 5:00 PM )
Language: