Currently I have a custom makefile rule as a pre-compile step to
create a version.go file that has something like `version = "123456"`.
I would like to switch to using goinstall instead of make for some
commands.
Wanting to include version information could be common for other
people, so could goinstall be taught that step or would it be too much
magic? It might only perform that step if there is an empty file
called "version.go". Or would this logic be a better fit for gomake
or the standard Makefiles?
Thoughts?
Thanks,
Tarmigan
What do you use the version number for?
A suggestion: rather than foisting this complexity onto goinstall, you
could use a pre-commit hook with your VCS to increment a version
counter in the code. That way you guarantee the version number is
intact and correct, even if you distribute the code outside the VCS
(as a tarball, for example).
Andrew
Just to identify (for debugging and support purposes) which version of
code someone is running if they have issues. Just like '8g -V'. So,
to address Kyle's point, it doesn't have security implications.
> A suggestion: rather than foisting this complexity onto goinstall, you
> could use a pre-commit hook with your VCS to increment a version
> counter in the code. That way you guarantee the version number is
> intact and correct, even if you distribute the code outside the VCS
> (as a tarball, for example).
It has those advantages, but doesn't work as well with distributed
development (both because of overlapping numbers and because hooks are
not propagated with new clones) or with branches (which are more
common in git than hg or svn). Another minor disadvantage for my use
is that the version info is a natural index into the VCS repository
whereas finding the version number from an incrementing number is an
extra step. Thanks for the suggestion: it may still work for me.
Thanks,
Tarmigan
I like that idea. Would there be any complication at link time from
multiple packages wanting to add (hopefully identical) information
with the same keys (if a subpackage gets imported through two
different top-level packages)?
> (If you were embedding anything in there that you didn't want anyone with a
> hex editor to be able to change, you'd want to find some way to sign it to
> prevent tampering, I don't think baked-in build information really falls
> into that category, though, as it can be forged in any number of other
> ways.)
Yeah, it's just for debugging and support. Like '8g -V'.
Thanks,
Tarm
I like that idea. Would there be any complication at link time from
multiple packages wanting to add (hopefully identical) information
with the same keys (if a subpackage gets imported through two
different top-level packages)?