profile
viewpoint

Ask questionsTry out the new Go generics proposal with go-linq

Go now has a prototype of generics implementation. Here are some resources:

  • https://blog.golang.org/generics-next-step
  • https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md
  • https://rakyll.org/generics-proposal/

This potentially could give a severe performance boost to go-linq, as well as actually make this library useful.

I haven't taken a closer look at how we would do this yet. For example, we might still end up having to do some type assertions. However, it might help us redesign the package and release a v4 if the generics proposal is adopted.

ahmetb/go-linq

Answer questions ahmetb

So I tried to imitate what From..Where..Select.. sort of thing would work. Each Where/Select/... would have different type parameters:

type Array[K any] []K

func (a Array[K]) Print[V any](v V) {
	for _, i := range a {
		fmt.Printf("%v-%v\n",i,v)
	}
}

However this is not supported by design. https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#methods-may-not-take-additional-type-arguments

useful!

Related questions

No questions were found.
source:https://uonfu.com/
answerer
Ahmet Alp Balkan ahmetb Google Seattle, WA https://ahmet.dev Senior software engineer at Google Cloud, on cloud-native technologies: Kubernetes/GKE and Cloud Run.
Github User Rank List