Skip to content

nice to have: faster generic instantiation location for serialization support #74331

Closed as not planned
@glycerine

Description

@glycerine

In generating serialization code for structs that contain parameterized generic types,
I current utilize "golang.org/x/tools/go/packages"

and its Load() function. To give specifics, see here for instance:

https://github.com/glycerine/greenpack/blob/master/parse/generics.go#L124

So greenpack serialization, abstractly similar to protocol buffers (which does
not support generics at all), can support some generic type serialization.

However it is off by default, since scanning for generics instantiation makes
"go:generate greenpack" very slow.

The Go compiler is fast, and must also do the work of locating and processing
instantiations during compilation.

It would be nice to be able to leverage this speed in serialization libraries too.

I don't know the most appropriate API, but perhaps awareness of the pain point
might enable a feature in the future to accomplish the aim described above
if an opportunity presented itself, or it even "almost feel out for free" during a refactor.

Generic types could then be truly first class citizens in Go data.

Again, not really a bug--just a "this would really be nice to have."

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions