I learned a neat trick in Go.
I have a VERSION file at the project root holding the current version number of DiceDB. I want to use this version everywhere I am referring to the version
- when the server runs
- version subcommand
- tests, and
- even baked in the binary
Instead of duplicating the version across the codebase, here’s an interesting hack using the current caller (check screenshot).
This, combined with the build-time injection of version variables, makes sure that even the binary has access to this version number without having to ship the VERSION file everywhere [that’s impactical anyways].