alecthomas / go_serialization_benchmarks

Benchmarks of Go serialization methods
https://alecthomas.github.io/go_serialization_benchmarks/
1.56k stars 158 forks source link

Idea: Switch from makefile to `go generate` instructions #163

Open matheusd opened 2 months ago

matheusd commented 2 months ago

Instead of relying on a makefile to generate bindings for the serializers that rely on code generation, we should move those instructions into each serializer package, so that it is their responsibility to keep them correct and up to date and also include instructions on the necessary setup needed to perform the codegen.

This would make the project more in line with purely go projects, removing the need to rely on an additional tool (make) to completely rebuild the project.

deneonet commented 2 months ago

I think the Makefile has to be redone anyways, because of the new structure of the repo. But im unsure how to get go generate to work cross-platform.

matheusd commented 2 months ago

Not sure what the issue with different platforms would be.

A standard directive would be something like //go:generate protoc --go_out=. structdef.proto from inside a package, so a go generate ./... would work just like in the makefile.

More complex generators could do something like //go:generate go run -tag build buildstuff.go, where buildstuff.go is a standard go program that will perform whatever complex task is needed to generate the bindings.

Some of the generators require third party programs to be installed (e.g. protoc) but that's no different than the current situation (and can be solved either through the prior method or some clever go module requirements).

deneonet commented 2 months ago

Didn't think about running a go program inside go generate, then there should be no issues. PR is welcomed!