The author outlines the challenges and solutions encountered while attempting to implement a generic collection type in Go. Despite the release of Go generics in version 1.18, comprehensive documentation and practical guides were missing, leading to numerous errors and false starts. By exploring different approaches and deeply

16m read timeFrom dolthub.com
Post cover image
Table of contents
IntroductionWhat we want to build: a sortable Set of any typeFalse start #1: Use two generic type parameters, copying slices.IndexFalse start #2: self-referential type definition without comparableThe secret syntax of generic type constraintsThe solutionTakeawaysCommentaryConclusion

Sort: