certspotterVersion: also allow -X=main.Version
debug.ReadBuildInfo() doesn't work for the Debian package, where there is no git repository (at best; could be the Debian packaging one). The go module doesn't have a version either. Add a quick shortcut at the top, that sets the version to main.Version if it's non-empty -- which is by default, so no change in behavior. Effectively, this allows one to use the standard -ldflags=-X=main.Version to set the version, like we intend to do in the Debian package.
This commit is contained in:
parent
6a6f74414a
commit
1a5f581c07
|
@ -30,10 +30,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var programName = os.Args[0]
|
var programName = os.Args[0]
|
||||||
|
var Version = ""
|
||||||
|
|
||||||
const defaultLogList = "https://loglist.certspotter.org/monitor.json"
|
const defaultLogList = "https://loglist.certspotter.org/monitor.json"
|
||||||
|
|
||||||
func certspotterVersion() string {
|
func certspotterVersion() string {
|
||||||
|
if Version != "" {
|
||||||
|
return Version
|
||||||
|
}
|
||||||
info, ok := debug.ReadBuildInfo()
|
info, ok := debug.ReadBuildInfo()
|
||||||
if !ok {
|
if !ok {
|
||||||
return "unknown"
|
return "unknown"
|
||||||
|
|
Loading…
Reference in New Issue