samber / lo

💥 A Lodash-style Go library based on Go 1.18+ Generics (map, filter, contains, find...)
https://pkg.go.dev/github.com/samber/lo
MIT License
18.02k stars 830 forks source link

Proposal lo.Chunk for map #533

Open kostya05983 opened 2 months ago

kostya05983 commented 2 months ago

Hello, I have a case where it would be great to have lo.chunk method for map. Below I provide an example of this case.

Sometimes, api can accept request with map, like:

var request map[string]RequestParams

where value RequestParams is parameters of request and key helps to identify your request in batch.

And api can accept maximum 50 elements in map.

Now if I need to process 500 items, I need to chunk it by myself and write additional code for chunking, it would be great to have such func in lo. I could make a PR for it, if you agree to add it. Also, I could provide more details about solution and problem