How to use generics with structs?

Viewed 37

For example i got two structs

type Video struct {
    Title string
    ...
}

type Playlist struct {
    Title string
    Videos []Video
    ...
}

and I want to use one function to process them, something like

type ytEntity { Video | Playlists | ... }
func getRecords[T ytEntity](entities []T) []Records

it is possible to do this with a single function instead of two that take []Videos and []Playlists?

0 Answers
Related