Limitations of Go generics

Go generics cannot be used with C types in cgo, limiting their use to pure Go code only.

Go generics are limited by the inability to use them with C types via cgo, the restriction of type parameters to interfaces or concrete types (not arbitrary C structs), and the lack of support for generic methods on interfaces. You cannot pass a generic type parameter directly to a C function or use it as a field in a struct that is exported to C.

// This fails: C types cannot be used as type parameters
// func GenericC[T C.int]() { ... } // Error: C.int is not a valid type parameter

// This fails: Generic types cannot be used in Cgo preambles
// #cgo LDFLAGS: -lmylib
// import "C"
// func CallC[T any](t T) { C.myfunc(t) } // Error: cannot use generic type T in C call

Simple terms: Go generics work only within pure Go code. You cannot use them to create generic wrappers for C libraries or pass generic types across the Go/C boundary. Think of generics as a tool that only works inside the Go house; it cannot reach out to the C yard.