Q: Is there anything else to this besides:

  • Type parameters
  • Type arguments (which can be omitted)
  • Type constants and unions types (which can be defined as new interface types)

? 🤔

⤋ Read More

I also like that they really are called “Type Parameters”, which is what they are, and not some god awful scary C++ bullshit templating garbage 😅

Starting with version 1.18, Go has added support for generics, also known as type parameters.

⤋ Read More

@prologic@twtxt.net see where its used maybe that can help.
https://github.com/sour-is/ev/blob/main/app/peerfinder/http.go#L153

This is an upsert. So I pass a streamID which is like a globally unique id for the object. And then see how the type of the parameter in the function is used to infer the generic type. In the function it will create a new *Info and populate it from the datastore to pass to the function. The func will do its modifications and if it returns a nil error it will commit the changes.

The PA type contract ensures that the type fulfills the Aggregate interface and is a pointer to type at compile time.

⤋ Read More

@prologic@twtxt.net see where its used maybe that can help.
https://github.com/sour-is/ev/blob/main/app/peerfinder/http.go#L153

This is an upsert. So I pass a streamID which is like a globally unique id for the object. And then see how the type of the parameter in the function is used to infer the generic type. In the function it will create a new *Info and populate it from the datastore to pass to the function. The func will do its modifications and if it returns a nil error it will commit the changes.

The PA type contract ensures that the type fulfills the Aggregate interface and is a pointer to type at compile time.

⤋ Read More

Participate

Login to join in on this yarn.