On Monday, 5 September 2022 at 09:12:53 UTC+1 harald....@gmx.net wrote: > small note here about the package naming -- to be taken with a larger > grain of salt, as usual: you repeat and thus "stutter" on > "Gothon/gothonSlice". I've looked into some existing slice generics > examples that now pop up like mushrooms after a warm shower. They tend to > simply stick with "slice" or "slices", even if this is deemed a **cough** > generic name (*pun might be intended*). >
You probably also want to look at these: https://github.com/golang/go/wiki/SliceTricks https://ueokande.github.io/go-slice-tricks/ The idiomatic way to do 'extend' is a = append(a, b...) For Index, there are other libraries available, including https://pkg.go.dev/golang.org/x/exp/slices#Index - the code <https://cs.opensource.google/go/x/exp/+/334a2380:slices/slices.go;l=106-113> is trivial though. For sets, unless you have special performance or space requirements, the go-to approach is to use a map with empty values. It doesn't have to use generics, but it can: https://go.dev/play/p/Cvy4fWdbYJj -- 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/8c107ea2-cdf1-4d31-ba90-9340ac4a2e3bn%40googlegroups.com.