version: fix version output for "go run"

Before (note attempted use of absent date and commit hash):

"short": "1.37.0-dev",
"long": "1.37.0-dev-t",

After:

"short": "1.37.0-ERR-BuildInfo",
"long": "1.37.0-ERR-BuildInfo",

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson 2023-02-10 21:52:58 -08:00 committed by Dave Anderson
parent 70a2929a12
commit b64d900f0f

View File

@ -134,6 +134,11 @@ func (i embeddedInfo) commitAbbrev() string {
ret.dirty = true
}
}
if ret.commit == "" || ret.commitDate == "" {
// Build info is present in the binary, but has no useful data. Act as
// if it's missing.
return embeddedInfo{}
}
return ret
})