mirror of
https://github.com/safedep/pmg.git
synced 2026-08-03 07:24:09 +02:00
* update pmg banner & fix empty commit * rm old banner * precompile regex for version * fix: Color in github URL (#128) --------- Co-authored-by: Abhisek Datta <abhisek.datta@gmail.com>
29 lines
393 B
Go
29 lines
393 B
Go
package version
|
|
|
|
import runtimeDebug "runtime/debug"
|
|
|
|
var (
|
|
Version string
|
|
Commit string
|
|
)
|
|
|
|
func init() {
|
|
buildInfo, ok := runtimeDebug.ReadBuildInfo()
|
|
if !ok {
|
|
return
|
|
}
|
|
|
|
if Version == "" {
|
|
Version = buildInfo.Main.Version
|
|
}
|
|
|
|
if Commit == "" {
|
|
for _, setting := range buildInfo.Settings {
|
|
if setting.Key == "vcs.revision" {
|
|
Commit = setting.Value
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|