Generics in Go
42mIntermediate2023-01-03
Authors

Anna-Katharina Wickert
Developer, Speaker
Course details
Repeating code by writing boilerplate code over and over again can often lead to mistake-ridden, messy code. In this course, Anna-Katharina Wickert shows you how to use generics in Go to write cleaner and easier-to-read code. Anna-Katharina shows how you can use generics—long on developers’ wishlists and introduced in Go 1.18—to write functions and types that work with a set of types instead of one concrete type. She covers type parameters, typesets, and type inference, and puts it all into practice with examples and looks into new packages shipped along with generics.
Skills covered
GoProgramming FoundationsGoogleProgramming LanguagesSoftware DevelopmentOne-Off
Concepts
0. Introduction
- 01 - Generics in Go 1.18
- 02 - What you should know
1. Type Parameters
- 03 - Type parameter 101
- 04 - Instantiation of generic functions
- 05 - Challenge - Type parameter with composite type
- 06 - Solution - Type parameter with composite type
2. Type Sets
- 07 - Type set 101
- 08 - Define type sets
- 09 - Experimental package - Constraints
3. Type Inference
- 10 - Function argument type inference
- 11 - Constraint type inference
4. Generics in Practice
- 12 - Best practice for usage
- 13 - Experimental package - Slices
- 14 - Experimental package - Maps
- 15 - Known limitations
Conclusion
- 16 - Next steps
Related courses
- Choosing the Right Back-End Language: TypeScript, Go, or Rust for Your Greenfield Project
- Go Standard Library
- Learning Go
- Developing Unicode-Aware Applications in Go
- Go for Developers: Practical Techniques for Effective Coding
- Effective Serialization In Go: JSON, Protocol Buffers and More
- Context Package In Go Lang
- Debugging in Go