At work recently; how would you use Go type constraints to ensure that users passed an argument as a pointer, and the argument implemented an interface on value receivers to prevent race conditions?
It's not quite Typescript levels of generic shenanigans but it's pretty cool! 🧵
It's not quite Typescript levels of generic shenanigans but it's pretty cool! 🧵
Comments
It builds up a constraint for a Task type, but then has an extra type (TaskPointer), and then returns a TaskReference of TaskPointer. What does TaskPointer do?
This is the critical bit!
Pretty cool!