type RowID interface {
int | string
}
type QueryWorker[ID RowID] interface {
findMoreRows(id ID) []ID
}
How do I implement this interface in a struct with concrete RowID? Following struct seems to not implement QueryWorker.
type someQuery struct {
QueryWorker[string]
}
func (b *someQuery) findMoreRows(id string) []string {
panic("implement me")
}
Update:
It seems like someQuery implements QueryWorker[string] but GoLand doesn't show any linkage b/w interface type QueryWorker[ID RowID] interface and implementation someQuery.
Also is there a way to store this implementation in a generic interface variable? Something like following doesn't compile:
type QueryWorkerWrapper struct {
// err: Interface includes constraint elements 'int', 'string', can only be used in type parameters
worker QueryWorker[RowID]
}
But following works fine:
type QueryWorkerWrapper struct {
stringWorker QueryWorker[string]
}