Hello everyone,
First and foremost, thanks a lot for putting this together, it's been
amazing.

I just wanted to let you guys know that generics is looking very promising
for me.

Without generics, my codebase has things like:
map_user, map_country, map_state etc, they basically take a collection of
db.user and return a collection of model.user, country and state
respectively. And I've heard people, why do you need generics there? Why
don't you write a map function which uses interfaces instead? I won't
defend my hate towards using empty interfaces, you want to use it, go ahead.

Another use case I have is in the data loader of my gqlgen project. For
every type of data loader, I'd need a way to manually sort them the way
they were requested, but with the new go tool, I'd simply have this
function once, and just it through it:
func DataLoader[TOut Model](ids []string, items []TOut) []TOut {
  mp := make(map[string]TOut, len(items))
  for _, item := range items {
    mp[item.GetId()] = item
  }
  result := make([]TOut, len(ids))
  for i, id := range ids {
    result[i] = mp[id]
  }
  return result
}

I just wanted to provide "In favor" perspective because from what I've seen
in the past, the people who like it will simply like it and not actually
send any "thanks for the new tool" kind of feedback.

Thanks again, generics is gamechanger for golang :)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOCqJrhv0H7aqvm5%2B5HayMd1h3DDjFFKV8D1CGqrTb-EgOc7HA%40mail.gmail.com.

Reply via email to