Open gedw99 opened 2 years ago
Yes, it would be a good idea. It should also be shown at startup.
Unfortunately, I don't think it is possible with current versions of Go. The runtime/debug.BuildInfo
function does not return useful information about the main module, only about dependencies. So I don't know how to do that in a portable way (recall that Galene builds fine on Windows, which does not necessarily have make or a sane shell).
In Go-1.18, due in December, runtime/debug.BuildInfo
provides information about the git hash from which Galene has been built. Perhaps something can be done with that, at least when Galene is built from a Git repository.
Just have a version.go file
and at compile time populate it
it a very common pattern used in golang .
ld flags can also be used but I don’t think you can read them at runtime.
@gedw99 I could be wrong, but I don't think that go build
supports running arbitrary code at build time. How do you suggest the version.go
file should be generated?
Found this about auto build versioning, seems to answer the question : https://www.atatus.com/blog/golang-auto-build-versioning/
Please add me to this issue. It would be nice to see a human readable version, either in the GUI or on the command line at start up. It makes raising issues, and you debugging them, much easier.
@jech here is an example: https://github.com/alda-lang/alda/blob/master/client/gen/version/main.go
i only had time to have a brief look. Maybe it helps !!
Alda is compiled using a Unix script:
https://github.com/alda-lang/alda/blob/master/client/bin/build
That script runs the code that you point at to generate the version file at compile time. This makes Alda impossible to cross-compile, at least out of the box, and impossible to build under Windows.
Compare this with Galene, which cross-compiles easily and builds under Windows without requiring a compatible shell.
hey @jech
ah i see. Ok maybe this helps : https://github.com/oligot/go-mod-upgrade/issues/19
Ok maybe this helps : oligot/go-mod-upgrade#19
This seems to depend on Taskfile. Let me stress once again that Galene can be built using just go build
, and I like it that way.
@jech i dont think it is dependent on Task file.
https://github.com/oligot/go-mod-upgrade does not have one.
Waiting on https://github.com/golang/go/issues/50603.
I used this: https://github.com/greenpau/versioned
Will try to make a PR, but got some issues with runtime at the moment with Caddy Reverse proxy and auth.
Noticed a lot of small bugs from people being reported.
Mit might be a good idea to have a page or something that shows:
Version of build ( githash ) User agent
you could even add a button that creates an issue and passes that data perhaps but that maybe not needed.