mirror of
https://github.com/miniflux/v2.git
synced 2025-08-26 18:21:01 +00:00
fix(version): allow build info to be set with LDFLAGS and fallback to VCS metadata when available
This commit is contained in:
parent
a010544200
commit
6bf3b3c464
1 changed files with 18 additions and 4 deletions
|
@ -7,11 +7,11 @@ import (
|
|||
"runtime/debug"
|
||||
)
|
||||
|
||||
// Variables populated at build time.
|
||||
// Variables populated at build time when using LD_FLAGS.
|
||||
var (
|
||||
Version = "Development Version"
|
||||
Commit = getCommit()
|
||||
BuildDate = getBuildDate()
|
||||
Version = ""
|
||||
Commit = ""
|
||||
BuildDate = ""
|
||||
)
|
||||
|
||||
func getCommit() string {
|
||||
|
@ -38,3 +38,17 @@ func getBuildDate() string {
|
|||
}
|
||||
return "Unknown (built outside VCS)"
|
||||
}
|
||||
|
||||
// Populate build information from VCS metadata if LDFLAGS are not set.
|
||||
// Falls back to values from the Go module's build info when available.
|
||||
func init() {
|
||||
if Version == "" {
|
||||
Version = "Development Version"
|
||||
}
|
||||
if Commit == "" {
|
||||
Commit = getCommit()
|
||||
}
|
||||
if BuildDate == "" {
|
||||
BuildDate = getBuildDate()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue