mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +00:00
Make sure some version information is set when no version was injected into the binary
Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
parent
1d2c951f2c
commit
ad1cb7e47e
2 changed files with 18 additions and 0 deletions
|
@ -240,6 +240,9 @@ func filterIssues(issues []*gosec.Issue, severity gosec.Score, confidence gosec.
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// Makes sure some version information is set
|
||||||
|
prepareVersionInfo()
|
||||||
|
|
||||||
// Setup usage description
|
// Setup usage description
|
||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime/debug"
|
||||||
|
)
|
||||||
|
|
||||||
// Version is the build version
|
// Version is the build version
|
||||||
var Version string
|
var Version string
|
||||||
|
|
||||||
|
@ -8,3 +12,14 @@ var GitTag string
|
||||||
|
|
||||||
// BuildDate is the date when the build was created
|
// BuildDate is the date when the build was created
|
||||||
var BuildDate string
|
var BuildDate string
|
||||||
|
|
||||||
|
// prepareVersionInfo sets some runtime version when the version value
|
||||||
|
// was not injected by the build into the binary (e.g. go get).
|
||||||
|
// This returns currently "(devel)" but not an effective version until
|
||||||
|
// https://github.com/golang/go/issues/29814 gets resolved.
|
||||||
|
func prepareVersionInfo() {
|
||||||
|
if Version == "" {
|
||||||
|
bi, _ := debug.ReadBuildInfo()
|
||||||
|
Version = bi.Main.Version
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue